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 {urn:schemas-microsoft-com:xslt-debug}current) 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)
You're getting this error when you save the XSLT file in the backoffice, because Umbraco executes your macro to test for some basic XML errors - at that point, $currentPage is not set to any page in your site, so any call to GetXmlNodeById() or NiceUrl() will fail because there's no node to take the @id attribute from. Furthermore, you're also making the assumption that the page referenced in the returnLink property will have at least one childnode, which you're trying to link to - that could easily fail if you're not careful which pages the macro will be running on.
If you check the "Ignore errors" checkbox, you can save the file and it will probably work fine on the website, however - it's much better to add some basic error handling inside the XSLT, by not calling those functions, unless there's an actual node available:
<!-- Do we have a returnLink? -->
<xsl:if test="normalize-space($currentPage/returnLink)">
<div class="tmpl4rtn">
<!-- Grab a reference to the node and its first child -->
<xsl:variable name="returnPage" select="umbraco.library:GetXmlNodeById($currentPage/returnLink)" />
<xsl:variable name="firstChild" select="$returnPage/*[@isDoc][1]" />
<!-- Is there a firstChild node? -->
<xsl:if test="$firstChild">
<ul>
<li>
<a href="{umbraco.library:NiceUrl($firstChild/@id)}">
<xsl:value-of select="concat('« ', $returnPage/@nodeName)" />
</a>
</li>
</ul>
</xsl:if>
</div>
</xsl:if>
Also, note how much easier it is to see what's going on by adding a few variables...
Need help with NiceUrl
Hi
I am trying to create a back link on a page, so I have set up a property which is a content picker.
I have then created an xslt and trying to grab the property that has been set and input into a nice url. An example of my code would be:
but doing this returns the error:
Could anybody help me please?
Thankyou
Hi Lee,
You're getting this error when you save the XSLT file in the backoffice, because Umbraco executes your macro to test for some basic XML errors - at that point,
$currentPage
is not set to any page in your site, so any call toGetXmlNodeById()
orNiceUrl()
will fail because there's no node to take the@id
attribute from. Furthermore, you're also making the assumption that the page referenced in the returnLink property will have at least one childnode, which you're trying to link to - that could easily fail if you're not careful which pages the macro will be running on.If you check the "Ignore errors" checkbox, you can save the file and it will probably work fine on the website, however - it's much better to add some basic error handling inside the XSLT, by not calling those functions, unless there's an actual node available:
Also, note how much easier it is to see what's going on by adding a few variables...
/Chriztian
is working on a reply...