i have an xml file like this.
<a>
<b>
<c>
<d>Text</d>
</c>
<c>
<d>Text</d>
</c>
</b>
<b>
<c>
<d>Text</d>
</c>
<c>
<d>Text</d>
</c>
</b>
</a>
I'm in <d>
node and i need to get the number of <c>
node inside <b>
. Be aware that this is just a sample so we can have deeper structure and <c>
will not be direct parent of <d>
.
So, what i need. I need to have in first <d>
node 1 (because we inside <c>
and it is first in <b>
) in the second 2, in third 1 and in fourth 2. We don't need to count all <c>
elements but only parents of current <d>
inside parent <b>
.
For now i have
count(preceding::c) . But it counts all 4 <c>
nods.
Please help. Thank you.
P.S. I'm using xsl 1.0