Copied to clipboard

Flag this post as spam?

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


  • jacob phillips 130 posts 372 karma points
    May 20, 2014 @ 01:11
    jacob phillips
    0

    node-set : Value was either too large or too small for an Int 32

    The node-set function is very useful for building custom variables.

    As I am new to using it, I have a basic question. I have the following variable which loops through some nodesets in the "storysTagged[#]" variable, picks ou the latest one, and then turns those results into a node-set:

    <xsl:for-each select="$storysTagged1" >
            <!-- sorted by date updated (latest first) -->
            <xsl:sort select="@updateDate" data-type="text" order="descending" />
            <!-- grab the first one's `@id` -->
            <xsl:if test="position() = 1">
                <nodeId><xsl:value-of select="@id" /></nodeId><tagUsed><xsl:value-of select="$storyTag1" /></tagUsed>
            </xsl:if>
    </xsl:for-each>
    
    <xsl:for-each select="$storysTagged2" >
            <!-- sorted by date updated (latest first) -->
            <xsl:sort select="@updateDate" data-type="text" order="descending" />
            <!-- grab the first one's `@id` -->
            <xsl:if test="position() = 1">
                <nodeId><xsl:value-of select="@id" /></nodeId><tagUsed><xsl:value-of select="$storyTag2" /></tagUsed>
            </xsl:if>
    </xsl:for-each>
    
    <xsl:for-each select="$storysTagged3" >
            <!-- sorted by date updated (latest first) -->
            <xsl:sort select="@updateDate" data-type="text" order="descending" />
            <!-- grab the first one's `@id` -->
            <xsl:if test="position() = 1">
                <nodeId><xsl:value-of select="@id" /></nodeId><tagUsed><xsl:value-of select="$storyTag3" /></tagUsed>
    </xsl:if>
    

    Then I can just loop through it later, like this:

    <xsl:for-each select="$latest">
    <xsl:variable name="taggedNode" select="umbraco.library:GetXmlNodeById(.)" />
    <xsl:value-of select="./@nodeName" />
    </xsl:for-each>
    

    It works fine.

    Next however, the need has arisen, that I need to pass more than just the nodeId in my variable, so I did this:

        <xsl:variable name="latestProxy">
            <!-- Loop taglists defined above, -->
            <xsl:for-each select="$storysTagged1" >
                    <!-- sorted by date updated (latest first) -->
                    <xsl:sort select="@updateDate" data-type="text" order="descending" />
                    <!-- grab the first one's `@id` -->
                    <xsl:if test="position() = 1">
                        <nodeId><xsl:value-of select="@id" /></nodeId>
             <tagUsed><xsl:value-of select="$storyTag1" /></tagUsed>
                    </xsl:if>
            </xsl:for-each>
            <xsl:for-each select="$storysTagged2" >
                    <!-- sorted by date updated (latest first) -->
                    <xsl:sort select="@updateDate" data-type="text" order="descending" />
                    <!-- grab the first one's `@id` -->
                    <xsl:if test="position() = 1">
                        <nodeId><xsl:value-of select="@id" /></nodeId>
             <tagUsed><xsl:value-of select="$storyTag2" /></tagUsed>
                    </xsl:if>
            </xsl:for-each>
            <xsl:for-each select="$storysTagged3" >
                    <!-- sorted by date updated (latest first) -->
                    <xsl:sort select="@updateDate" data-type="text" order="descending" />
                    <!-- grab the first one's `@id` -->
                    <xsl:if test="position() = 1">
                        <nodeId><xsl:value-of select="@id" /></nodeId>
             <tagUsed><xsl:value-of select="$storyTag3" /></tagUsed> 
    </xsl:if>
    </xsl:for-each>
    
    <xsl:for-each select="$storysTagged4" >
                    <!-- sorted by date updated (latest first) -->
                    <xsl:sort select="@updateDate" data-type="text" order="descending" />
                    <!-- grab the first one's `@id` -->
                    <xsl:if test="position() = 1">
                        <nodeId><xsl:value-of select="@id" /></nodeId>
             <tagUsed><xsl:value-of select="$storyTag4" /></tagUsed>
                    </xsl:if>
            </xsl:for-each>
        </xsl:variable>
    
    <!-- Create an XPath-navigable version of that set -->
    <xsl:variable name="latest" select="make:node-set($latestProxy)" />
    

    But I get an error:

    System.OverflowException: Value was either too large or too small for an Int32. 
     at System.Convert.ToInt32(Double value) 
     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  (3)(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
     at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
     at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) 
     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)
    

    This is strange because looking through the forums, I see this example:

       <!-- List files to include for specific pages -->
        <xsl:variable name="file-mapper">
            <page id="31415">
                <css>pi.css</css>
                <script>math.js</script>
            </page>
            <page id="1984">
                <css>bigbrother.css</css>
            </page>
        </xsl:variable>
        <!-- Make XPath-navigable node-set from the above variable -->
        <xsl:variable name="files" select="msxml:node-set($file-mapper)" />
    

    ..And so I'm a bit puzzled. In fact, even in the first example, when I create the node-set like this:

    <!-- Create an XPath-navigable version of that set -->
    <xsl:variable name="latest" select="make:node-set($latestProxy)" />
    

    I still get the error.

    Am I missing something? Why do I get the error and what do I have to do to fix it so I can build more flexible XML in variables?

  • jacob phillips 130 posts 372 karma points
    May 20, 2014 @ 01:24
    jacob phillips
    0

    holy crap, this editor is driving me insane! Reposting question....

  • jacob phillips 130 posts 372 karma points
    May 20, 2014 @ 01:35
    jacob phillips
    0

    The node-set function is very useful for building custom variables.

    As I am new to using it, I have a basic question. I have the following variable which loops through some nodesets in the "storysTagged[#]" variable, picks ou the latest one, and then turns those results into a node-set:

    <xsl:variable name="latestProxy">
        <!-- Loop taglists defined above, -->
    
        <xsl:for-each select="$storysTagged1" >
                <!-- sorted by date updated (latest first) -->
                <xsl:sort select="@updateDate" data-type="text" order="descending" />
                <!-- grab the first one's `@id` -->
                <xsl:if test="position() = 1">
                    <nodeId><xsl:value-of select="@id" /></nodeId><tagUsed><xsl:value-of select="$storyTag1" /></tagUsed>
                </xsl:if>
        </xsl:for-each>
    
        <xsl:for-each select="$storysTagged2" >
                <!-- sorted by date updated (latest first) -->
                <xsl:sort select="@updateDate" data-type="text" order="descending" />
                <!-- grab the first one's `@id` -->
                <xsl:if test="position() = 1">
                    <nodeId><xsl:value-of select="@id" /></nodeId><tagUsed><xsl:value-of select="$storyTag2" /></tagUsed>
                </xsl:if>
        </xsl:for-each>
    
        <xsl:for-each select="$storysTagged3" >
                <!-- sorted by date updated (latest first) -->
                <xsl:sort select="@updateDate" data-type="text" order="descending" />
                <!-- grab the first one's `@id` -->
                <xsl:if test="position() = 1">
                    <nodeId><xsl:value-of select="@id" /></nodeId><tagUsed><xsl:value-of select="$storyTag3" /></tagUsed>
      </xsl:if>
    </xsl:for-each>
    <xsl:for-each select="$storysTagged4" >
                <!-- sorted by date updated (latest first) -->
                <xsl:sort select="@updateDate" data-type="text" order="descending" />
                <!-- grab the first one's `@id` -->
                <xsl:if test="position() = 1">
                    <nodeId><xsl:value-of select="@id" /></nodeId><tagUsed><xsl:value-of select="$storyTag3" /></tagUsed>
      </xsl:if>
    </xsl:for-each>
    
    <!-- Create an XPath-navigable version of that set -->
    <xsl:variable name="latest" select="make:node-set($latestProxy)/nodeId" />
    

    Then I can just loop through it later, like this:

    It works fine.

    Next however, the need has arisen, that I need to pass more than just the nodeId in my variable, so I did this:

     <xsl:variable name="latestProxy">
         <!-- Loop taglists defined above, -->
         <xsl:for-each select="$storysTagged1" >
                 <!-- sorted by date updated (latest first) -->
                 <xsl:sort select="@updateDate" data-type="text" order="descending" />
                 <!-- grab the first one's `@id` -->
                 <xsl:if test="position() = 1">
                     <nodeId><xsl:value-of select="@id" /></nodeId>
         <tagUsed><xsl:value-of select="$storyTag1" /></tagUsed>
                 </xsl:if>
         </xsl:for-each>
         <xsl:for-each select="$storysTagged2" >
                 <!-- sorted by date updated (latest first) -->
                 <xsl:sort select="@updateDate" data-type="text" order="descending" />
                 <!-- grab the first one's `@id` -->
                 <xsl:if test="position() = 1">
                     <nodeId><xsl:value-of select="@id" /></nodeId>
         <tagUsed><xsl:value-of select="$storyTag2" /></tagUsed>
                 </xsl:if>
         </xsl:for-each>
         <xsl:for-each select="$storysTagged3" >
                 <!-- sorted by date updated (latest first) -->
                 <xsl:sort select="@updateDate" data-type="text" order="descending" />
                 <!-- grab the first one's `@id` -->
                 <xsl:if test="position() = 1">
                     <nodeId><xsl:value-of select="@id" /></nodeId>
         <tagUsed><xsl:value-of select="$storyTag3" /></tagUsed> 
                </xsl:if>
         </xsl:for-each>    <xsl:for-each select="$storysTagged4" >
                 <!-- sorted by date updated (latest first) -->
                 <xsl:sort select="@updateDate" data-type="text" order="descending" />
                 <!-- grab the first one's `@id` -->
                 <xsl:if test="position() = 1">
                     <nodeId><xsl:value-of select="@id" /></nodeId>
         <tagUsed><xsl:value-of select="$storyTag4" /></tagUsed>
                 </xsl:if>
         </xsl:for-each>
     </xsl:variable>
    
    
        <!-- Create an XPath-navigable version of that set --> <xsl:variable name="latest" select="make:node-set($latestProxy)" />
    

    But I get an error:

    System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) 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 (3)(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) 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)

    This is strange because looking through the forums, I see [this][1] example:

    <script>math.js</script>

    ..And so I'm a bit puzzled. In fact, even in the first example, when I create the node-set like this:

    I still get the error.

    Am I missing something? Why do I get the error and what do I have to do to fix it so I can build more flexible XML in variables?

    [1]: http://our.umbraco.org/forum/developers/xslt/9360-xsl-if-array?p=0#comment34272

  • jacob phillips 130 posts 372 karma points
    May 20, 2014 @ 02:10
    jacob phillips
    0

    Actually, I see that my error was two-fold.

    1) I need the extra items that I want to pass to be children of the existing

    So for example, in my node building variable...I nest the new item I want to pass, like this:

    <nodeId><xsl:value-of select="@id" /><tagUsed><xsl:value-of select="$storyTag3" /></tagUsed></nodeId>
    

    2) When I access those items, I will need to so a little differently.

    Like this:

        <xsl:variable name="taggedNode" select="umbraco.library:GetXmlNodeById(./text())" />
    

    To build my node.

    And like this to get at my item:

                <xsl:value-of select="./tagUsed/text()"/>
    
  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 20, 2014 @ 09:45
    Chriztian Steinmeier
    101

    Hi Jacob,

    I would recommend you did something like this instead:

    <node tag="{$storyTag3}" id="{@id}" />
    

    When you do the other thing, you're creating what's called mixed content (your <nodeId> contains both text - the id - and elements - <tagUsed>) which becomes tricky (as you found out).

    This way you can store whatever you need from the original node.

    To get the values you adjust to this:

    <xsl:variable name="taggedNode" select="umbraco.library:GetXmlNodeById(@id)" />
    
    <xsl:value-of select="@tag"/>
    

    /Chriztian

  • jacob phillips 130 posts 372 karma points
    May 20, 2014 @ 20:39
    jacob phillips
    0

    Awesome thanks.

    I tried using the apply-templates approach based on the earlier example, but I ran into some problems. I needed to get it done, so I reverted to this modified approach. I will try and detail it when I get a chance because I really want to master that.

Please Sign in or register to post replies

Write your reply to:

Draft