xml - How to append a counter to element names using XSLT -


I'm trying to use XSLT to change it:

  Lt; Parents & gt; & Lt; Parent & gt; & Lt; Child val = "bill" /> & Lt; ChildB val = "tom" /> & Lt; / Parent & gt; & Lt; Parent & gt; & Lt; Child Val = "Jake" /> & Lt; ChildB val = "sue" /> & Lt; / Parent & gt; & Lt; / Parent & gt;  

In:

  & lt; Parents & gt; & Lt; ChildA1 val = "Bill" /> & Lt; ChildB1 val = "tom" /> & Lt; Childa 2 Val = "Jake" /> & Lt; ChildB2 val = "sue" /> & Lt; / Parent & gt;  

& lt; Disclaimer> Target XML, I do not have to choose for any purpose, except for the integration with the system designed by Goodwill Troll. Unfortunately, now I am facing one of them (a system, which is not a troll). & lt; / Disclaimer>

I am starting with complex valuable elements, and I need to merge my children in a long list used to differentiate children from numbers one another goes.

I know that a single & lt; Parent & gt; XSLT can be used to change the element into its two hair elements Is there any way that I can do this by automatically adding numbers to take advantage of a counter from XSLT Transformer?

Good if you type as xsl: number

Pre> & lt; Xsl: template match = "Parents / Parent / *" & gt; & Lt; Xsl: variable name = "index" & gt; & Lt; Xsl: number level = "any" /> & Lt; / Xsl: variable & gt; & Lt; Xsl: element name = "{name ()} {index $}" & gt; & Lt; Xsl: copy-of select = "@ * | node ()" /> & Lt; / XSL: element & gt; & Lt; / XSL: Templates & gt;

You can create element names with the count of elements of the same name at different levels, but usually with the XML, name this one element after the name of an element Not good, if you really want an index, then put it into a specialty or child element dedicated to that specialty.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -