I'm getting stucked.
Following problem is to be solved (hope the schematic sample will describe it):
inpu xml:
<greatgrandfather> <grandfather> <father> <child>foo</child> </father> <father> <child>boo</child> </father> </grandfather>
<grandfather> <father> <child>doo</child> </father> </grandfather> </greatgrandfather>
expected output xml:
<greatgrandfather> <grandfather> <father> <child>0</child> </father> <father> <child>1</child> </father> </grandfather> <grandfather> <father> <child>2</child> </father> </grandfather> </greatgrandfather>
goal
My goal is to replace the child's value with their index appearance within this xml, kind of counter.
What I already did:
I took the transformer XMLUpdater with
UpdateType = Replace contents
XML Path = greatgrandfather/grandfather/father/child XQuery = let $count := 0 for $elem in //child let $count := $count +1 return $count
This gives me back
<greatgrandfather> <grandfather> <father> <child>1 1 1</child> </father> <father> <child>1 1 1</child> </father> </grandfather> <grandfather> <father> <child>1 1 1</child> </father> </grandfather> </greatgrandfather>
I don't see the wood for the trees. Can anybody help me?
Thanks in advance!