Reputation: 591
in xsl we can write two condition in cycle "for each". for example instead of
<xsl:when test="/document/line[
(substring(field[@id='0'], 1,3)='MAR')
] and
/document/line[
contains(substring(field[@id='0'],123,4),'0010')
]">
we can write it:
<xsl:for-each select="/document/line[
contains(substring(field[@id='0'], 1,3),'MAR')
] and
/document/line[
contains(substring(field[@id='0'],123,4),'0010')
]">
Best regards
Update from comments
<xsl:for-each select="/document/line[
contains(substring(field[@id='0'], 1,3),'MAR')
and contains(substring(field[@id='0'],123,4),'0010')
]">
Upvotes: 7
Views: 35594
Reputation: 27360
If the question is "is it possible to check 2 conditions in a select attribute of a for-each" the answer is: NO. Because
The expression must evaluate to a node-set. (from ZVON)
Hence the data type of the select must be a node-set not a boolean value.
But, if you want to select two node-sets inside a xsl:for-each
or xsl:template
(the latter is better) etc., you can use the union operator (|):
<xsl:for-each select="/document/line[
contains(substring(field[@id='0'], 1,3),'MAR')
] |
/document/line[
contains(substring(field[@id='0'],123,4),'0010')
]">
Upvotes: 12