I have the following xml:
<root xmlns:s="http://example.com/schema">
<foo>
<s:bars>
<s:bar name="normal">bar101</s:bar>
<s:bar name="special">Foobar</s:bar>
<s:bar name="super">FuBar</s:bar>
</s:bars>
</foo>
</root>
I use the following xslt template to output elements bar:
<xsl:template match="root">
<foos>
<xsl:apply-templates select="foo/s:bars"/>
</foos>
</xsl:template>
<xsl:template match="s:bars/s:bar[@name='special' or @name='super']">
<xsl:element name="{@name}">
<xsl:text>special value:</xsl:text>
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="s:bars/s:bar">
<xsl:element name="{@name}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
Oddly enough, this outputs the following xml when using the .NET XSLT processor:
<foos>
<normal>bar101</normal>
<special>Foobar</special>
<super>FuBar</super>
</foos>
Apparently, the template for is s:bars/s:bar[@name='special' or @name='super']not used. I was expecting the following output:
<foos>
<normal>bar101</normal>
<special>special value:Foobar</special>
<super>special value:FuBar</super>
</foos>
I tried adding an extra template to select bars
<xsl:template match="s:bars">
<xsl:comment>bars</xsl:comment>
<xsl:apply-templates />
</xsl:template>
but this did not change the result (but added <!--bars-->to the result to invoke the template.)
It seems that I expect something different from the rules of the template or misunderstanding them. Should the attributes of the AND element be matched by coincidence on the ONLY element?
XSLT-, .Net XSLT-?