I'm using a standard sitemap XSLT template, but want it to start on level 2 rather than level 1. Here is the code, starting at level 1, which works perfectly:
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>
To this...
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=2]"/>
I get an error:
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, IList`1 parent)
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)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable
input, XsltArgumentList arguments, XmlWriter results, XmlResolver
documentResolver)
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)
Thanks Jan, but it still gives the same error, as does number(2) and number('2'). This is actually for a multi-tier nested navigation system, so I've just used the Flexible Navigation package and that sorted me out, although the XSLT is way more complex in there than I think it should be now.
Are you getting this error when you are visualising against the homepage?
I've tested your code against my setup and this it is only when I test using a page whose level is less than 2 that I get the error. This is happening because you are (understandably) using ancestor-or-self here:
<xsl:with-paramname="parent"select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>
This will throw an error as nothing matches.
A workaround could be to keep the initial match the same but change:
<xsl:for-eachselect="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap]">
to:
<xsl:for-each select="$parent/* [(@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap) and @level >= 2]">
Sitemap from level 2
Hi,
I'm using a standard sitemap XSLT template, but want it to start on level 2 rather than level 1. Here is the code, starting at level 1, which works perfectly:
But when I change this...
To this...
I get an error:
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, IList`1 parent)
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)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
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)
Can anyone suggest what's going wrong?
Thanks!
Hi Dan
try adding '' around the 2. So it reads @level='2'
I think that should help.
/Jan
Thanks Jan, but it still gives the same error, as does number(2) and number('2'). This is actually for a multi-tier nested navigation system, so I've just used the Flexible Navigation package and that sorted me out, although the XSLT is way more complex in there than I think it should be now.
Hi Dan
Ok, what happens if you check the "skip error testing" and save the file? Does it then still fail on your website?
/Jan
I tried that actually and it just gave the standard: Error parsing XSLT file.
Are you getting this error when you are visualising against the homepage?
I've tested your code against my setup and this it is only when I test using a page whose level is less than 2 that I get the error. This is happening because you are (understandably) using ancestor-or-self here:
This will throw an error as nothing matches.
A workaround could be to keep the initial match the same but change:
to:
Hope this helps!
Have you tried using the ?umbracodebugshowtrace=true when you're viewing the page to see if you get some better error description?
/Jan
is working on a reply...