xsl-list
[Top] [All Lists]

[xsl] How to insert a set nodes under the root of an arbitrary XML using XSL?

2011-01-07 15:07:54

I would love to know how to (using XSL) insert a pre-determined node a
(with children b and c) as a child of the root node of an arbitrary XML.  I
know how to apply the XSL once I've got it.  I just need help with the XSL.
All the examples I'm finding online assume a pre-determined XML, which I
cannot in this case.

For example

 [root]
  [node]text[/node]
  [othernode]text[/othernode]
 [/root]

 should look like when finished:

 [root]
  [a][b]text1[/b][c]text2[/c][/a]             <-------  inserted
  [node]text[/node]
  [othernode]text[/othernode]
 [/root]

Most importantly, please note that any solutions with hard-coded references
to any node names (other than those I want to insert) are not usable for
me.  I have no control over the schema of the XML into which I'm sticking
these other nodes.  I know only that it's a valid XML file and the root has
at least one child.  The above example is a purely made up example designed
to illustrate the question.

Thanks!


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--