I am using a XSLT Transformer in Java. I am sure the problem is in the way I’m typing in the XSLT syntax.
Basically, I have to see if an attribute ‘id’ in one of the nodes of XML is equivalent to a value, the XSL should process a template. I need to pass this test value as a xsl:param. When I test it on a static value, it works cool:
<ul class="levelOneNav">
<xsl:for-each select="level1[@id='sub-page-1']">
<xsl:call-template name="level1"/>
</xsl:for-each>
<div class="clear"></div>
</ul>
The testing portion is in second line above. AFAIK to put in a param inside the strings, the format is <xsl:for-each select="level1[@id='$ContentID']"> in which $ContentID is the xsl:param declared as <xsl:param name="ContentID"/>
So this is the code I’m keying in
<ul class="levelOneNav">
<xsl:for-each select="level1[@id='$ContentID']">
<xsl:call-template name="level1"/>
</xsl:for-each>
<div class="clear"></div>
</ul>
but it doesn’t work. I’ve also tried using <xsl:for-each select="level1[@id='{$ContentID}']">
and it also fails.
Any advise is appreciated greatly. Please give me links if you feel I should learn something. Thanks for your time …
No, that “AFAIK” is where you are wrong. Some string values in XSLT attributes certainly do accept a
"{$param}"syntax (note the braces), but in your case what you are after is much simpler:@id=$ContentIDEDIT: Note that the ‘{$param}’ applies for XSLT attributes, see example: