Using parameter for attributename
I wonder if it is possible to pass a parameter to a stylesheet and use this parameter as an attributename, like:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="utf-8" indent="yes" />
<xsl:param name="environment" />
<xsl:template match="/">
<xsl:element name="rootelement">
<xsl:apply-templates select="*[($environment = '1') or not ($environment)]" />
</xsl:element>
</xsl:template>
<xsl:template match="*[($environment = '1') or not ($environment)]">
... some transformation
</xsl:template>
</xsl:stylesheet>
In the XML-document every element has an attribute, that has the name of the parameter passed to the stylesheet. It's value can be 0 or 1. Eventually I want to end up with only those elements, whose attribute $environment has a value of 1.
Many thanks in advance,
Raoul.
|