I have an XML file which contains the following:
<contents id="MLC1" name="Requirement1" uri="C:\abc.txt" xsi:type="requirement:Requirement" type="">
<contents id="GO1" name="Goal1" uri="C:\abc.txt" xsi:type="goal:Goal">
I am trying to match all the element within my XML file, which has the attribute xsi:type="requirement:Requirement" so that I can add a new attribute called "label" to it. This is my stylesheet:
<xsl:template match="//contents[@type='requirement:Requirement']">
<contents>
<xsl:attribute name="label">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</contents>
</xsl:template>
I have already declared xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" in my stylesheet, but it seems that it is unable to match anything. I am suspecting it is because there is also another attribute "type" in the original xml which does not have the xsi namespace. Does anyone has any suggestion what should I use to match this element correctly?
No comments:
Post a Comment