Copied to clipboard

Flag this post as spam?

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


  • Kate 267 posts 610 karma points
    Jan 16, 2013 @ 15:11
    Kate
    0

    umbraco.library:GetMedia problem

    I dont understand why I get an error in this kode.
    If I ignore errors it works fine.

    The code looks lige this

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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="/">

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/testBillede, 0)" />
    <xsl:if test="$media != ''">
    <xsl:variable name="url" select="$media/umbracoFile" />
    <xsl:variable name="width" select="$media/umbracoWidth" />
    <xsl:variable name="height" select="$media/umbracoHeight" />
    <img src="{$url}" width="{$width}" height="{$height}" />
    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    And the error like this

    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)

    Hope that someone can explain it for me :-)

    Thanks

  • Mike Chambers 636 posts 1253 karma points c-trib
    Jan 16, 2013 @ 15:25
    Mike Chambers
    1

    just add a check 

    <xsl:if test="number($currentPage/testBillede) &gt; 0">

     

    it's just alerting you to the fact that as testBilleded could well be empty or not an int...

  • Kate 267 posts 610 karma points
    Jan 16, 2013 @ 15:31
    Kate
    0

    Do you mean like this:

    <xsl:if test="number($currentPage/testBillede) &gt; 0">
            <xsl:variable name="url" select="$media/umbracoFile" />
            <xsl:variable name="width" select="$media/umbracoWidth" />
            <xsl:variable name="height" select="$media/umbracoHeight" />
            <img src="{$url}" width="{$width}" height="{$height}" />
     </xsl:if>

    That still gives me an error

    I thourght I did check by doing like this:

    <xsl:iftest="$media != ''">
  • Kate 267 posts 610 karma points
    Jan 16, 2013 @ 15:35
    Kate
    0

    If I just have this in my xslt it still fails:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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="/">

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/testBillede, 0)" />


    </xsl:template>

    </xsl:stylesheet>


  • Kate 267 posts 610 karma points
    Jan 16, 2013 @ 16:10
    Kate
    0

    Okay, I got it :-)

    <xsl:template match="/">
    <xsl:if test="number($currentPage/testBillede) &gt; 0">
    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/testBillede, 0)" />

    <xsl:if test="$media">
    <xsl:variable name="url" select="$media/umbracoFile" />
    <xsl:variable name="width" select="$media/umbracoWidth" />
    <xsl:variable name="height" select="$media/umbracoHeight" />
    <img src="{$url}" width="{$width}" height="{$height}" />
    </xsl:if>
    </xsl:if>

    </xsl:template>

    Thanks Mike
    Sorry, it took me a while to figure out what you meant :-)

Please Sign in or register to post replies

Write your reply to:

Draft