Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonas Høiby 62 posts 53 karma points
    Oct 12, 2009 @ 13:05
    Jonas Høiby
    0

    CMS bug or XSLT error? - System.OverflowException ..

    To get a better understanding of XSLT ..

     

     

    why does:

    <xsl:param name="topXnews" select="macro/macroTopX" />

    +

    <xsl:for-each select="DTF_Extension:StayNews($topXnews)/Root/Stay">

    =

     

    Error occured
    
    System.OverflowException: Value was either too large or too small for an Int32. 
    at System.Convert.ToInt32(Double value) 
    at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) 
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) 
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType) 
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) 
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator type, XPathNavigator topXnews) 
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter) 
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results) 
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results) 
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) 
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

     

     

    But when i "skip testing" .. theres nothing wrong with the XSLT? :-s


  • Sebastiaan Janssen 5045 posts 15478 karma points MVP admin hq
    Oct 12, 2009 @ 13:30
    Sebastiaan Janssen
    1

    Because the "StayNews" method expects a value, and as the parser can never be sure that a value is present, it throws an exception.

    The fix is easy, surround you for each with a test:

    <xsl:if test="$topXnews != ''">
     <xsl:for-each select="DTF_Extension:StayNews($topXnews)/Root/Stay">
    </xsl:if>
  • Jannik Nilsson 38 posts 81 karma points
    Oct 12, 2009 @ 13:34
    Jannik Nilsson
    1

    I think its because there is nothing for the for-each to evaluate. Try putting this around:

    <xsl:if test="$topXnews != ''">
        <xsl:for-each select="DTF_Extension:StayNews($topXnews)/Root/Stay">
            <!-- Do something -->
        </xsl:for-each>
    </xsl:if>
  • Jannik Nilsson 38 posts 81 karma points
    Oct 12, 2009 @ 13:35
    Jannik Nilsson
    0

    Damn too late :)

  • Sebastiaan Janssen 5045 posts 15478 karma points MVP admin hq
    Oct 12, 2009 @ 13:36
    Sebastiaan Janssen
    0

    Haha, great answer Jannik :-)

  • Jonas Høiby 62 posts 53 karma points
    Oct 12, 2009 @ 13:49
    Jonas Høiby
    0

    thanks guys .. so .. its a bit like the media-picker ""problem"" when extracting images .. :-)

     

    but why does my other extensions not behave the same way then? they are almost identical?

  • dandrayne 1138 posts 2262 karma points
    Oct 12, 2009 @ 13:55
    dandrayne
    0

    To clarify, this is because the xslt parser checks the xslt using the top node as a reference.  If your root node doesn't contain these properties an error will be thrown.  Disabling testing will allow the file to save and work, but as it will also hide any other errors throwing a test around your loop is the best way to go.

Please Sign in or register to post replies

Write your reply to:

Draft