using XSL to replace XML nodes with new nodes

Posted by iHeartGreek on Stack Overflow See other posts from Stack Overflow or by iHeartGreek
Published on 2010-06-01T19:16:14Z Indexed on 2010/06/01 19:23 UTC
Read the original article Hit count: 384

Filed under:
|
|
|

I need an XSL solution to replace XML nodes with new nodes.

Say I have the following existing XML structure:

<root>
    <criteria>
        <criterion>AAA</criterion>
    </criteria>
</root>

And I want to replace the one criterion node with:

<criterion>BBB</criterion>
<criterion>CCC</criterion>
<criterion>DDD</criterion>

So that the final XML result is:

<root>
    <criteria>
        <criterion>BBB</criterion>
        <criterion>CCC</criterion>
        <criterion>DDD</criterion>
    </criteria>
</root>

I have tried using substring-before and substring-after to just copy the first half of the structure, then just copy the second half (in order to fill in my new nodes in between the two halves) but it appears that the substring functions only recognize text in between the nodes' tags, and not the tags themselves like I want them to. :( :(

Any other solutions?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xslt