XSLT Conditionally processing sibling attributes



I am fairly new to XSLT and have been a very novice user till now. It would be great if someone could help me in achieving below trivial task.



I have an XML element like below:



<element
addr="::"
value="1"
>

Now, I want to modify the value of 'value' to "0" if addr is "::".

A logical solution for me would be something like below:



<xsl:template match="element/@*">
<xsl:if test="@addr = '::'">
<xsl:message>Matched</xsl:message>
<xsl:attribute name="value">0</xsl:attribute>
</xsl:if>
<xsl:copy>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>

But this does not seem to work for me. How can I correct this thing ?


Thanks


No comments:

Post a Comment