Using the Umbraco interface, I'm having an issue passing a variable into the GetMedia function in the code below. If I hardcode the value 1065, the code works fine. If I pass in $mediaCollection, it fails to validate, but the value of the variable is 1065.
The interesting part is that if I select the checkbox to ignore errors, the XSLT file saves OK and it works. But with the box unchecked, it reports the error:
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, 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)
I've found other topics in the forums about similar issues, but haven't been able to resolve mine using their suggestions. This might be my understanding though.
It's not preventing me from progressing with my projcet, but obviously something is wrong, and it's best not to sweep these things under the carpet in my experience - they generally come back to bite.
Issue with GetMedia call and variable as Int32
Hi all,
Using the Umbraco interface, I'm having an issue passing a variable into the GetMedia function in the code below. If I hardcode the value 1065, the code works fine. If I pass in $mediaCollection, it fails to validate, but the value of the variable is 1065.
The interesting part is that if I select the checkbox to ignore errors, the XSLT file saves OK and it works. But with the box unchecked, it reports the error:
The XSLT code is here:
I've found other topics in the forums about similar issues, but haven't been able to resolve mine using their suggestions. This might be my understanding though.
It's not preventing me from progressing with my projcet, but obviously something is wrong, and it's best not to sweep these things under the carpet in my experience - they generally come back to bite.
Can anyone help?
Thanks
Rich
PS - ignore the text area - that was for debugging purposes.
I think it happens when you're using a variable that might not be present at the time when saving.
But when you run it on the actual website it'll work just fine.
So it's not a problem with your XSLT.
Try this:
<xsl:variable name="mediaItems" select="umbraco.library:GetMedia(number($mediaCollection), 1)"/>
Try changing this line:
to this:
/Kim A
is working on a reply...