I want to match two expression using OR statement in xsl:apply-templates select.i want to check following conditions...
<xsl:apply-templates select="//w:body/w:p[w:r[w:t]] or //w:body/w:p[w:r[w:pict]]">
// My Functionality
</xsl:apply-templates>
But i dont know how i do this. Please Guide me to get out of this issue...
I don't know about XSLT 2.0, but in XSLT 1.0 <xsl:apply-templates select="//w:body/w:p[w:r[w:t]] or //w:body/w:p[w:r[w:pict]]">
isn't valid query. Use |
instead of or
.
You can use or
, and it's really correct to use it in this context because you don't want the testing nodes:
<xsl:apply-templates select="
//w:body
/w:p
[w:r/w:t or w:r/w:pict]">
|
(union) is indispensabile only if you need to select the testing nodes (w:t
and w:pict
):
<xsl:apply-templates select="
//w:body/w:p/w:r/w:t
|
//w:body/w:p/w:r/w:pict">
where XPath 2.0 allows you to write more concisely:
<xsl:apply-templates select="
//w:body/w:p/w:r/(w:t|w:pict)"/>