<!-- start writing XSLT --> <xsl:value-of select="$currentPage/mediaItem"/> // Its returning 1052 <xsl:value-of select="umbraco.library:GetMedia($currentPage/mediaItem, 'false')"/> // Here is the error. </xsl:template>
</xsl:stylesheet>
When i use <xsl:value-of select="umbraco.library:GetMedia($currentPage/mediaItem, 'false')"/>
then its throwing 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)
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)
If i use <xsl:value-of select="umbraco.library:GetMedia(1052, 'false')"/>
Then its perfect.Please tell me whats wrong in the above code.
You should wrap the GetMedia calls in a check to verify you have a value. The reason is that when you press Save, Umbraco does a quick test of your XSLT file. In this test it may not have a value for $currentPage/mediaItem - and this will cause an exception as GetMedia is expecting an integer. Also this could happen if you run the macro on a page that doesn't have any media selected.
So you can handle both situations by wrapping it in a test to ensure there is a value:
GetMedia System.OverflowException: Value was either too large or too small for an Int32.
Hi,
I am new to umbraco and working on media files and getting some problems.Please have a look at them and tell me where i am wrong.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:value-of select="$currentPage/mediaItem"/> // Its returning 1052
<xsl:value-of select="umbraco.library:GetMedia($currentPage/mediaItem, 'false')"/>
// Here is the error.
</xsl:template>
</xsl:stylesheet>
When i use <xsl:value-of select="umbraco.library:GetMedia($currentPage/mediaItem, 'false')"/>
then its throwing 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)
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)
If i use <xsl:value-of select="umbraco.library:GetMedia(1052, 'false')"/>
Then its perfect.Please tell me whats wrong in the above code.
Thanks
Hi,
You should wrap the GetMedia calls in a check to verify you have a value. The reason is that when you press Save, Umbraco does a quick test of your XSLT file. In this test it may not have a value for $currentPage/mediaItem - and this will cause an exception as GetMedia is expecting an integer. Also this could happen if you run the macro on a page that doesn't have any media selected.
So you can handle both situations by wrapping it in a test to ensure there is a value:
Hope this helps,
Tom
is working on a reply...