I have this xslt to convert a csv to xml, works fine, except the tag is the same for all columns. I need it to increment like this
Although XSLT is capable of processing non-XML content, it seems to not be intended as a general-purpose text transformation tool. As a result, most of the tools available to you are about manipulating XML infoset constructs like elements and attributes. There is a little support for text strings, but not much. So position()
is defined in terms of input nodes.
http://www.w3.org/TR/xpath/#section-Node-Set-Functions:
The position function returns a number equal to the context position from the expression evaluation context.
http://www.w3.org/TR/xslt#section-Expressions:
the context position comes from the position of the current node in the current node list; the first position is 1
Since your input is just a text string, you are always in position 1. I can think of only one way to do this with XSLT. Transform twice. The first transform gives you the basic structure with un-numbered column elements. The second transform numbers the column elements. Because you are selecting nodes from an XML document the second time, position()
should have the values you want.