Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • edu martinezdesalinas 2 posts 22 karma points
    Mar 16, 2010 @ 09:31
    edu martinezdesalinas
    0

    how to convert umbraco.library:RenderTemplate parameter to int32

    umbraco 4.0.3 IIS6 W2K3R2 .net 3.5 sp1

    Hi, on an xslt template I'm trying to supply umbraco.library:RenderTemplate with /macro/bannerNodeId (as per method signature). The macro parameter is defined as a number. Not sure what's wrong with this (see exception below when trying to save xslt). I also tried to passing an xml node as parameter, then assign /macro/xmlNode/@id to bannerNodeId, no luck either. Any help really appreciated :-)

    <xsl:template match="/">

    <xsl:variable name="bannerNodeId" select="/macro/bannerNodeId"/>

    <xsl:value-of select="umbraco.library:RenderTemplate($bannerNodeId)" disable-output-escaping="yes"/>
    </xsl:template>

    exception stack:

    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)

  • Neil Campbell 58 posts 182 karma points
    Mar 16, 2010 @ 09:40
    Neil Campbell
    1

    Hi Eduardo,
    What you are doing is fine, you just need to wrap an if statement around the value-of statement to check that $bannerNodeId is not empty.

    So it should be:

    <xsl:template match="/">

    <xsl:variable name="bannerNodeId" select="/macro/bannerNodeId"/>

    <xsl:if test="$bannerNodeId != ''">
       <xsl:value-of select="umbraco.library:RenderTemplate($bannerNodeId)" disable-output-escaping="yes"/>
    </xsl:if>

    </xsl:template>

    Hope this helps

    Cheers,
    Neil

     

  • edu martinezdesalinas 2 posts 22 karma points
    Mar 17, 2010 @ 08:58
    edu martinezdesalinas
    0

    worked like a charm - thanks Neil!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies