[xsl] sequential numbering with for-each

Subject: [xsl] sequential numbering with for-each
From: "a kusa akusa8@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 30 Aug 2016 17:57:08 -0000
Hello:

I have a situation where I need to iterate over an element twice and
output sequential numbers.

I have two input files:

First XML file. foo occurrence is 1 to infinity

<root>

<foo type="f1">
<foo1>ok</foo1>
<foo1>not ok</foo1>
</foo>

</root>

Second XML file. tables can occur 1 to infinity. tab1 can also occur 1
to infinity.

<root1>

<table ttype="f1">

<tables>
<tab1>
Data1
</tab1>

<tab1>
Data2
</tab1>


</tables>
<tables>
<tab1>
......
</tab1>
<tab1>
Data3</tab1>
</tables>
</table>
</root1>

The logic is:

for each /root/foo[@type = @ttype from 'root1']/foo1

repeat tab1

Desired output:

1. Data1 - ok
2.Data1 - not ok
3.Data2 - ok
4.Data2 - not ok
5.Data3 -ok
6.Data3-not ok

I am able to get the individual 'tab1' elements to repeat. But my
sequential numbering label is off. If I use position() within for-each
it resets for every call in the for-each loop.

I get:

1. Data1 - ok
2.Data1 - not ok
1.Data2 - ok
2.Data2 - not ok
1.Data3 -ok
2.Data3-not ok


Any ideas or suggestions on how to make this work will be appreciated.

Current Thread