System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) 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 System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) 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 think this line is causing problem for you <xsl:variablename="media"select="umbraco.library:GetMedia((concat('$currentPage','/','$imageProperty')),0)"/>
just put this line <xsl:if test="$imageProperty>0">
Thanks for your help, but the imageProperty is not ID of the image ( and I know I can pass ID but I would liket to pass the property name) , it is the property name of the image. like imgHeader.
so what I need is to create a dynamic xpath that can generate $currentPage/imgHeader with something similar to this $currentPage/$imageProperty
concatenate variables umbraco 4.7
Hi,
I am trying to create a macro that can accept 2 parameters, property name of an image and image cropper type.
I would liket to concatenate these two to generate an image as follows can anyone tell me what is 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" xmlns:ucomponents.cms="urn:ucomponents.cms" xmlns:ucomponents.dates="urn:ucomponents.dates" xmlns:ucomponents.media="urn:ucomponents.media" xmlns:ucomponents.members="urn:ucomponents.members" xmlns:ucomponents.nodes="urn:ucomponents.nodes" xmlns:ucomponents.search="urn:ucomponents.search" xmlns:ucomponents.strings="urn:ucomponents.strings" xmlns:ucomponents.urls="urn:ucomponents.urls" xmlns:ucomponents.xml="urn:ucomponents.xml" xmlns:ucomponents.io="urn:ucomponents.io"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ucomponents.cms ucomponents.dates ucomponents.media ucomponents.members ucomponents.nodes ucomponents.search ucomponents.strings ucomponents.urls ucomponents.xml ucomponents.io ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:param name="sizeType" select="macro/sizeType" />
<xsl:param name="imageProperty" select="macro/imageProperty"/>
<xsl:template match="/">
<xsl:variable name="media" select="umbraco.library:GetMedia((concat('$currentPage','/','$imageProperty')),0)" />
<xsl:if test="$media">
<xsl:choose>
<xsl:when test="$sizeType">
<xsl:variable name="imgSrcCrop" select="concat(substring-before($media/umbracoFile,'.'),'_',$sizeType,'.jpg')" />
<img src="{$imgSrcCrop}" alt="{$media/imgAltTxt}" />
</xsl:when>
<xsl:otherwise>
<img src="{$media/umbracoFile}" alt="{$media/imgAltTxt}" />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
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 System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
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 tried this too , but still no luck!!!
<xsl:variable name="media" select="umbraco.library:GetMedia(concat($currentPage,'/',$imageProperty),0)" />
Hi
I think this line is causing problem for you <xsl:variable name="media" select="umbraco.library:GetMedia((concat('$currentPage','/','$imageProperty')),0)" />
just put this line <xsl:if test="$imageProperty>0">
Thanks
what I figured out is I need an DYNAMIC XPATH. like $currentPage/$imageProperty. can anyone help me on this ?
Thanks
Ali
Hi Pasang,
Thanks for your help, but the imageProperty is not ID of the image ( and I know I can pass ID but I would liket to pass the property name) , it is the property name of the image. like imgHeader.
so what I need is to create a dynamic xpath that can generate $currentPage/imgHeader with something similar to this $currentPage/$imageProperty
hope that makes sense
Thanks
Ali
Hi Ali
Maybe this can help you out:
<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/*[name()=$imageProperty],0)" />
/Kim A
Hi Kim,
That's exactly what I was looking for. brilliant.
You are legend
Thanks mate.
Ali
Cool, great to hear Ali. Glad to help :)
/Kim A
Hi Andersen,
Actually i am new to umbraco. the same situation came for me please let me know how to solve this. Please find my xsly file below. thanks in advance
<?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"/>
<!-- start writing XSLT -->
<xsl:template match="/">
<xsl:param name="sourcePaths" select="macro/sourcePath" />
<xsl:param name="siteimage" select="concat(concat('$currentPage','/',$sourcePaths),'/','imageurl/')" />
<xsl:variable name="mediaId" select="number($siteimage)" />
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:if test="$mediaNode/umbracoFile">
<img src="{$mediaNode/umbracoFile}" height="{@umbracoHeight}" width="{@umbracoWidth}" alt="($mediaNode/nodeName)" />
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
is working on a reply...