It is not considered good design to put index or count numbers into XML element or attribute names, as you seem to want to do. As for "holding state", unless you play with XSLT 3.0 accumulators or iterate there is no directly comparable concept but of course you can write templates or functions (functions since XSLT 2.0) which take parameters and call themselves recursively, passing on the state in a parameter. Whether all that is necessary is difficult to tell, so far you have only shown the output you want but no input you want to process and how the input is mapped to the output.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|