Suppose I have a xml
<Root>
<TB>
..
</TB>
<TB>
..
</TB>
<TB>
..
<DIACT>2</DIACT>
</TB>
<TB>
...
<DIACT>3</DIACT>
</TB>
<TB>
----
<DIACT>4</DIACT>
---
</TB>
</Root>
I want to get the position of first TB node where DIACT is not null or DIACT node exist, using xslt mapping. Like in this case postion should give me output as 3. As 3rd TB node is the first one with DIACT not null.
Use:
As you need this for futher procesing, set a variable that has the above value:
Alternatively, one can use
xsl:number:Here is a simple demo of the two techniques:
when this transformation is applied on the provided XML document:
two correct results are produced: