I’m trying to apply an xsl template based on multiple conditions such as:
Apply the same template if
-> a child of node exists OR
-> a node exists
e.g:
<root>
<data>
<test>VVV</test>
<item>AAA</item>
<item>BBB</item>
</data>
</root>
I need to apply the same template under either of 2 conditions:
- if data/item exists or
- if data exists
After parsing through the root, tried the below:
<xsl:apply-templates select=”data/item | data” mode=”testMode” />
Expected result:
If data/item is present, then call the template at that element level, else, if data is present, call the same template.
But in my case, whenever data/item is present, its applying the template twice: first at level then at the data/item level which is not as expected.