Copied to clipboard

Flag this post as spam?

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


  • Chris 11 posts 53 karma points
    Sep 15, 2011 @ 16:59
    Chris
    0

    Cant GetMedia($variable, true()) work with a variable?

    i want to collect all images in a media folder. I have this code, where 1143 id the id of my folder:

    <xsl:for-each select="umbraco.library:GetMedia(1143, true())/*">
      <xsl:if test="./@id">
        <xsl:variable name="im" select="umbraco.library:GetMedia(./@id, false())"/>
        <img src="{$im/umbracoFile}" alt="" />
      </xsl:if>
    </xsl:for-each>

    This works fine. However, I want the id to be collected from my document. So I replace 1143 with $currentPage/bildemappe, leaving the code like this:

    <xsl:for-each select="umbraco.library:GetMedia($currentPage/bildemappe, true())/*">
      <xsl:if test="./@id">
        <xsl:variable name="im" select="umbraco.library:GetMedia(./@id, false())"/>
        <img src="{$im/umbracoFile}" alt="" />
      </xsl:if>
    </xsl:for-each>
    The above will not be saved in umbraco, and gives me an error message: 

    ---

    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)
    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) 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 dont understand why this doesnt work. If I test $currentPage/bildemappe I get exactly the value I want. 

     

  • Chris 11 posts 53 karma points
    Sep 15, 2011 @ 17:08
    Chris
    0

    I found the answer:

    Actually it worked the whole time, it was only umbraco who would not validate my xslt. 

    I had no test, to check if  $currentPage/bildemappe  was empty or not. When I added that, I got no errors!

    Final code looks like this:

    <xsl:variable name="imFolder" select="$currentPage/bildemappe"/>
    <xsl:if test="$imFolder != ''">
      <xsl:for-each select="umbraco.library:GetMedia($imFolder, true())/*">
        <xsl:if test="./@id">
          <xsl:variable name="im" select="umbraco.library:GetMedia(./@id, false())"/>
          <img src="{$im/umbracoFile}" alt="" />
        </xsl:if>
      </xsl:for-each>
    </xsl:if>
Please Sign in or register to post replies

Write your reply to:

Draft