Effective use of <xsl:param>

webmasterbeta

New Member
Okay, I can't even select a single node based on a param. Here's the XML:
<nonformulary>
<drug>
<brandname>Cozaar</brandname>
</drug>
</nonformulary

Here's the XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"/>
<xsl:param name="brandname"/>

<xsl:template match="/">

<xsl:element name="nonformulary">
<xsl:element name="item"><xsl:value-of select="$brandname"/></xsl:element>

<xsl:for-each select="/nonformulary/drug[brandname='$brandname']">
<xsl:element name = "drug">
<xsl:element name="brandname"><xsl:value-of select="brandname"/></xsl:element>
</xsl:element>
</xsl:for-each>

</xsl:element>
</xsl:template>

</xsl:stylesheet>

And finally, when passed a param of 'Cozaar', here's the resulting XML:
<?xml version="1.0" encoding="UTF-16"?><nonformulary><item>Cozaar</item></nonformulary>
The problem must be in my select for the xsl:for-each statement. If I have the value 'Cozaar' in my param (as seen in the new 'item' element), then how do I select all drugs that have a brandname of 'Cozaar'?
 
Back
Top