Search In
Learn from 350 other Umbracians at the annual Umbraco Conference - CodeGarden '13. More than twenty high quality sessions, open spaces, hackathons and social events you'll remember. Not to be missed! Less than 25 tickets left - get yours now!
I'm getting some weird results using @id on the niceUrl function. Basically it works with a hard code value. But throws the exception if i use an imported value. Do i need to convert to an int. How would i do that from with a the macro.
XSLT.
<!-- if use this value the error message is returned --> <xsl:param name="datasource" select="macro/datasource"/>
<!-- if i use $parentNode/@id error message is return --> <xsl:param name="parentNode" select="umbraco.library:GetXmlNodeById($datasource)"/>
<!-- if i use <xsl:param name="nodeId" select="1132" /> <xsl:template match="/"> <!-- start writing XSLT --> <a class="leftArrow backLink" href="{umbraco.library:NiceUrl($datasource)}"> <xsl:value-of select="$parentNode/@nodeName"/> </a>
<h5> <!-- this works correctly --> <xsl:value-of select="$parentNode/data [@alias = 'heading']"/> </h5>
Error message
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) 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)
You can do 2 things here.
1. check the 'skip testing', thet probably saves the file correctly and should work at the front-end as well (taking that you do not have any other errors in the xslt)
2. Add an extra check:
<xsl:if test="$datasource != '' ">
<xsl:param name="parentNode" select="umbraco.library:GetXmlNodeById($datasource)"/>
</xsl:if>
HTH,
PeterD
cool, all working. thanks Peter.
Hi - I have this same problem - except I dont think i can use that fix - at the moment i get "cannot use xsl:if beneath xsl:stylesheet directive" basically a global param at the top of the template like so
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($currentPage/spotImage, false())" />
<xsl:template match="/">
Have you tried adding an @isDoc check in?
It fixed it for me..
Anyone got an actually working version of this xslt for 4.6?
None of the above solutions fixes the problems :/
<xsl:variable name="source" select="/macro/source"/>
<a href="{umbraco.library:NiceUrl(number($source))}" >Go</a>
will do it.
Could you tell me where I have to change theses lines ? I'm new to Umbraco, and using JQGallery 1.1 (tried 1.2 too) with umbraco 4.7 and nothing seems to get this to work...
Thank you very much
Hi Lacroix
Do you get the exact same error on your page as mentioned above? If so yo can go to the "Developer" section and choose the XSLT folder where you should be able to find your file, and do the trick Peter suggests in the post marked as the solution.
Hope this helps.
/Jan
I had this same issue: my parameter was defined without a value, and I solved it by giving it a default value:
Before:
<xsl:param name="thumbnailImageId"/><a rel="{umbraco.library:NiceUrl($thumbnailImageId)}"></a>
After:
<xsl:param name="thumbnailImageId" select="0"/><a rel="{umbraco.library:NiceUrl($thumbnailImageId)}"></a>
I had the same issue:
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, IList`1 currentPage, XPathNavigator propertyName) 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)