I'm looking for an xslt that does the following:
With the input xml of, for example:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<foo1>bar1</foo1>
<foo2>bar2^bar3^bar4</foo2>
<foo3>bar3^bar3</foo3>
<unknown>more data</unknown>
</root>
I want to copy all of the existing nodes to the resultant xml. I won't know what all the nodes are, i.e. I won't know that I'm receiving a foo1
node, I just want to copy them over directly. For certain nodes though, I do know what they are and I want to split them by a delimiter and number them accordingly, as below.
<?xml version="1.0" encoding="UTF-8"?>
<root>
<foo1>bar1</foo1>
<foo2>
<foo2-1>bar2</foo2-1>
<foo2-2>bar3</food2-2>
<foo2-3>bar4</foo2-3>
</foo2>
<foo3>
<foo3-1>bar3</foo3-1>
<foo3-2>bar3</food2-2>
</foo3>
<unknown>more data</unknown>
</root>
Any help would be greatly appreciated.
Thanks.
This is fairly easy to do in XSLT 2.0:
In XSLT 1.0 you would need to use a recursive template call. For example: