Is an IF statement or condition permitted?
No, but XPath has an or operator - note that XPath is case sensitive.
XPath expression in the provided code :
node = '1' or node='2'
is syntactically correct .
or is the standard XPath operator and can be used to combine two subexpressions .
[33] OperatorName :: = 'and' | 'or' | 'mod' | 'Div'
Here is a complete XSLT conversion example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="num[ . = 3 or . = 5]"/> </xsl:stylesheet>
When this conversion is applied to the following XML document :
<nums> <num>01</num> <num>02</num> <num>03</num> <num>04</num> <num>05</num> <num>06</num> <num>07</num> <num>08</num> <num>09</num> <num>10</num> </nums>
the desired, correct result is created (all elements are copied except for <num>03</num> and <num>05</num> :
<nums> <num>01</num> <num>02</num> <num>04</num> <num>06</num> <num>07</num> <num>08</num> <num>09</num> <num>10</num> </nums>
Dimitre novatchev
source share