Many thanks to everyone who offered help with my stylesheet. Everyone's
suggestions worked when using a hardcoded value for the attribute name.
But I need to use parameters.
this is what I've tried so far. Is there another way?
thanks,
Ann Marie
<xsl:param name="attr">ROSE</xsl:param>
<xsl:param name="value">RED</xsl:param>
<xsl:param name="node">orion-web-app</xsl:param>
<xsl:template match="orion-web-app">
<!-- adds attr to orion-web-app node correctly but won't
take vars for attr or match="$node" -->
<xsl:copy>
<xsl:if test="not(//@ROSE)">
<xsl:attribute name="ROSE"><xsl:value-of
select="$value"/></xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:if>
</xsl:copy>
</xsl:template>
If i include the attr test in this template:
<xsl:template match="@*" priority="10">
<!-- adds attr to each node in the tree
it should only be added to the specified node
and vars are not allowed where ROSE is used -->
<xsl:if test="not(//@ROSE)">
<xsl:attribute name="ROSE"><xsl:value-of
select="$value"/></xsl:attribute>
</xsl:if>-->
to get around the restriction on where attribute names can be used, I
tried this:
<xsl:template match="@*" priority="10">
<!--replaces every attr in the result tree w/ RED
recoverable error: Cannot write an attribute node when no
element start tag is open-->
<xsl:choose>
<xsl:when test="not(//@*=$attr)"><xsl:value-of
select="$value"/></xsl:when>
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
</xsl:choose>