简体   繁体   中英

XSLT Template not using parameter

I cannot get the xslt parameter zoneid to be used:

    <xsl:template name="ad">
    <xsl:param name="zoneid" />
    <script><![CDATA[
    var m3_u = (location.protocol=='https:'?'https://XX.php':'http://XX.php');
    var m3_r = Math.floor(Math.random()*99999999999);
    if (!document.MAX_used) document.MAX_used = ',';
    document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
    document.write ("?zoneid={$zoneid}"/>&amp;target=_blank");]]></script>
    </xsl:template>

Now I run the template by this:

 <xsl:template name="ad_300x600">
 <xsl:param name="state" />
 <xsl:param name="locid" />
 <xsl:when test="$state='FL'"><xsl:call-template name="ad"><xsl:with-param name="zoneid">341</xsl:with-param></xsl:call-template></xsl:when>
 </template>

And here is the resulting HTML:

        <script>
        var m3_u = (location.protocol=='https:'?'https://XX.php':'http://XX.php');
        var m3_r = Math.floor(Math.random()*99999999999);
        if (!document.MAX_used) document.MAX_used = ',';
        document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
        document.write ("?zoneid={$zoneid}"/>&amp;target=_blank");
        </script>

As you can see in the resulting HTML Its saying {$zoneid} .

I've also tried <xsl:value-of select="$zoneid"/> with no luck either.

Not sure what to do here.

You are trying to use the syntax of attribute value templates within literal text content.

This simply does not work - the XSLT engine doesn't look for AVTs in text content.

To output the variable you need to end the CData section, add a <xsl:value-of select="$zoneid"/> (and start a new CData section afterwards).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM