Copied to clipboard

Flag this post as spam?

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


  • Paolo G. 6 posts 26 karma points
    Mar 23, 2012 @ 23:32
    Paolo G.
    0

    Problem with ordering of nodes

    Hello, i have a XSLT to display a sidebar a menu, but I have a big problem for sorting. I have this line:

     <xsl:sort select="@sortOrder" order="descending" data-type="number"></xsl:sort>

    and output work perfectly. But i want the ordering by "ascending". When I change to option to:

     <xsl:sort select="@sortOrder" order="ascending" data-type="number"></xsl:sort>

    The script cannot display any output and I have this error on fronted: "Error parsing XSLT file:" On backend I have this error: "Error occurred 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) [...]"

    Here the complete code: http://codepaste.net/tiq668

    Can you help me please?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 24, 2012 @ 18:08
    Lee Kelleher
    0

    Hi Paolo,

    The issue is with the value of the "Id" variable.  Since it is used with GetXmlNodeById, it must be a numeric value, but the fall-back value is "no".

    You could either wrap a condition around the rest of your mark-up... to test that the value is not "no", or set it to a default value?

    <xsl:if test="$Id != 'no'">

    Put this above the "Prima" variable, and the closing </xsl:if> at the end of that template.

    Cheers, Lee.

  • Paolo G. 6 posts 26 karma points
    Mar 25, 2012 @ 23:42
    Paolo G.
    0

    Hi Lee, thank you for your reply.

    I have added the code you have indicated, but I have the same error on frontend (Error parsing XSLT file: \xslt\umbSidebarSx1.xslt) if I set the order as asc:

    <xsl:sort select="@sortOrder" order="ascending" data-type="number" />

    if I set the order as desc, everything is ok. I don't understand it.. can you help me?

    Here the complete code:

    http://codepaste.net/oioo7t

    Thank you.

  • Paolo G. 6 posts 26 karma points
    Mar 28, 2012 @ 11:03
    Paolo G.
    0

    Up! :)

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 28, 2012 @ 11:11
    Lee Kelleher
    0

    Hi Paolo,

    I've had a look at your XSLT snippet, I can't see any reason why swapping "descending" with "ascending" should cause a problem.

    The error message "Error parsing XSLT file" implies that there is something structurally wrong with the XSLT.  Are you still getting the "OverflowException" when saving from the back-office?

    - Lee

  • Paolo G. 6 posts 26 karma points
    Mar 28, 2012 @ 11:33
    Paolo G.
    0

    Hi Lee, no, now the issue of "OverflowException" is resolved (thank you for your tip)!

    I can't see any reason why swapping "descending" with "ascending" should cause a problem, too, but I have this issue :(

    Thank you, Paolo.

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Mar 28, 2012 @ 15:33
    Dan Okkels Brendstrup
    2

    Can you add an ?umbDebugShowTrace=true parameter to your URL when you get the error, and post the actually error message (highlighted in red) here?

  • Paolo G. 6 posts 26 karma points
    Mar 28, 2012 @ 17:51
    Paolo G.
    0

    @Dan: thank you for the support.

    Here the error:

    umbracoMacro InnerException Value was either too large or too small for an Int32.
    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 System.Xml.Xsl.CompiledQuery.Query.(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces, IList`1 post) in C:\inetpub\wwwroot\xslt\umbSidebarSx1.xslt:line 66
      at System.Xml.Xsl.CompiledQuery.Query.(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in C:\inetpub\wwwroot\xslt\umbSidebarSx1.xslt:line 50
      at System.Xml.Xsl.CompiledQuery.Query.(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double )
      at System.Xml.Xsl.CompiledQuery.Query.Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
      at System.Xml.Xsl.CompiledQuery.Query.Execute(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.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters)
      at umbraco.macro.loadMacroXSLT(macro macro, MacroModel model, Hashtable pageElements)

     

    I don't understand... with desc work fine, with asc not.. The numbers are the same..

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 28, 2012 @ 18:07
    Lee Kelleher
    1

    Hi Paolo,

    I think I know what it is.  When you are gathering the nodes in the "Prima" and "Successive" variables, you are using "descendant::node()" - which will get all none document/content nodes too (e.g. includes property nodes).  So when you (eventually) pass these nodes through to the "showSuccessive" template, some of them wont have an "id" attribute, which means NiceUrl is throwing an error.

    Quickest fix is correcting the root cause:

    <xsl:variable name="Successive" select="umbraco.library:GetXmlNodeById($Id)/descendant::*[@isDoc]" />

    Cheers, Lee.

  • Paolo G. 6 posts 26 karma points
    Mar 28, 2012 @ 18:16
    Paolo G.
    0

    Hi Lee, you are a guru! :) Now work perfectly :)

    Thank you very very much!

    Cheers, Paolo.

Please Sign in or register to post replies

Write your reply to:

Draft