how to find if a node exists with the attribute value using xslt?
suppose if my xml like this
<root>
<sub>
<p>text</p>
<title id='id1-num-444'>text</title>
<p>text</p>
<title id='id1-str-aaa'>text</title>
<p>text</p>
<title id='id1-num-333'>text</title>
<p>text</p>
</sub>
</root>
i used the following xsl
<xsl:template match ="sub">
....some tags...
<xsl:if test ="contains(name(), 'title[@id='id1-num']')">
<xsl:call-template name ="title"></xsl:call-template>
</xsl:if>
</xsl:template>
The if condition need to check till num, it shouldn’t consider anything after num.
Thanks.
If you want to test on part of an attribute value, you need to use
contains(), but of course, not quite the way you did.Assuming, as Sean Durkin said, that your focus is on a candidate title element,
or the slightly less explicit
will do the trick.