Copied to clipboard

Flag this post as spam?

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


  • nielsrobin 5 posts 22 karma points
    Jul 01, 2010 @ 15:55
    nielsrobin
    0

    Having trouble using variable from macro

    So i built a simpel slideshow macro (code below). Which all works great except for one detail. I'm not using my "source" variable to get the right folder in the media library. The problem is when i try to, that is replace "1198" with "$source", it says: "System.OverflowException: Value was either too large or too small for an Int32."

    The weird think is that i'm using it in the line above "s{$source"}" .. were it correctly returns "s1198". What am i doing wrong, since it doesn't want to recognize my variable as an Int32?

     

    <?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:variable name="source" select="/macro/source"/>
    
    <xsl:template match="/">
    
    <div class="slideshow s{$currentPage/@id} s{$source}">
    <xsl:for-each select="umbraco.library:GetMedia(1198, 'false')/node">
       <xsl:choose>
         <xsl:when test="umbraco.library:GetMedia(@id, 'false')/data [@alias = 'umbracoFile']">
    
            <img src="{umbraco.library:GetMedia(@id, 'false')/data [@alias = 'umbracoFile']}" alt="{@nodeName}" />
    
         </xsl:when>
         <xsl:otherwise>
          <!--Do something with the directory-->
         </xsl:otherwise>
        </xsl:choose>
    </xsl:for-each>
    </div>
    
    </xsl:template>
    
    </xsl:stylesheet>

     

  • Rich Green 2246 posts 4008 karma points
    Jul 01, 2010 @ 15:56
  • nielsrobin 5 posts 22 karma points
    Jul 01, 2010 @ 16:06
    nielsrobin
    0

    Wrapping 

    <xsl:if test="$source != '' ">
    </xsl:if>

    around did the trick. Thanks Rich.

Please Sign in or register to post replies

Write your reply to:

Draft