homeNode is a node above/or the current node and headerImageFolder is a mediapicker property (a media folder is selected) and this contains the id of the selected folder. When i save it i get the following error. However if i hard code the value instead of using the mediafolderId variable in the call to GetMedia it works fine.
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) 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 should probably check to see if the mediaFolderId returns a result (even if you know that it should). See Lee Kelleher's blog post on how to use GetMedia, it's excellent!
I've noticed that in xslt if you declare a variable set to an id of a node and you dont specify the if test, as kipusoep mentions above, i've almost always get the error you showed above.
why does this not work
homeNode is a node above/or the current node and headerImageFolder is a mediapicker property (a media folder is selected) and this contains the id of the selected folder. When i save it i get the following error. However if i hard code the value instead of using the mediafolderId variable in the call to GetMedia it works fine.
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)
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)
Regards
Sean
I think the problem is, that XSLT doesn't know if $mediaFolderId will be a valid integer, could you try this:
<xsl:variable name="mediaFolderId" select="number($homeNode/data[@alias='headerImageFolder'])" />
You should probably check to see if the mediaFolderId returns a result (even if you know that it should). See Lee Kelleher's blog post on how to use GetMedia, it's excellent!
Sorry, that's not correct, use this instead:
Just another reason to use .NET instead of XSLT ;-)
thanks i'll get that a try
Hi seanrock,
I've noticed that in xslt if you declare a variable set to an id of a node and you dont specify the if test, as kipusoep mentions above, i've almost always get the error you showed above.
seanrock,
I've posted an issue something similar to you my xslt is as follows:
<xsl:param name="currentPage"/>
<xsl:variable name="ID" select="$currentPage/data [@alias = 'galleryImages']"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:if test="$ID > 0">
<xsl:variable name="mediaItems" select="umbraco.library:GetMedia($ID, true())"/>
<xsl:for-each select="$mediaItems/node">
<img>
<xsl:attribute name="src">
<xsl:text>/umbraco/imagegen.ashx?image=</xsl:text>
<xsl:value-of select="current()/data[@alias='umbracoFile']"/>
<xsl:text>&width=300</xsl:text>
</xsl:attribute>
</img>
</xsl:for-each>
where galleryImages is the mediapicker property set to a sub folder under the media folder.
is working on a reply...