  | |  | mege two separate xml nodes into one | mege two separate xml nodes into one 2007-05-24 - By Mukul Gandhi
Following is a solution for this:
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="AllBooks"> <AllBooks> <BookList> <xsl:for-each select="*/*"> <Book id="{position()}"> <xsl:copy-of select="@*[not(name() = 'id')]" /> </Book> </xsl:for-each> </BookList> </AllBooks> </xsl:template>
</xsl:stylesheet>
On 5/24/07, Alan Andrade <alan.andrade@(protected)> wrote: > > > > How do I mege the 2 nodes? > > INPUT: > > > > <AllBooks> > > <BookList1> > > <Book id="1" upc= "1" someotherID= "booklist1" salePrice= "1"/> > > <Book id="3" upc= "3" someotherID= "booklist1" salePrice= "3"/> > > <Book id="4" upc= "4" someotherID= "booklist1" salePrice= "4"/> > > </BookList1> > > <BookList2> > > <Book id="2" upc= "2" someotherID= "booklist2" salePrice= "2"/> > > <Book id= "3" upc= "3" someotherID= "booklist2" salePrice= "3"/> > > <Book id= "4" upc= "4" someotherID= "booklist2" salePrice= "4"/> > > <Book id= "5" upc= "5" someotherID= "booklist2" salePrice= "5"/> > > </BookList2> > > </AllBooks> > > > > OUTPUT: > > > > <AllBooks> > > <BookList> > > <Book id="1" upc= "1" someotherID= "booklist1" salePrice= "1"/> > > <Book id="2" upc= "3" someotherID= "booklist1" salePrice= "3"/> > > <Book id="3" upc= "4" someotherID= "booklist1" salePrice= "4"/> > > <Book id="4" upc= "2" someotherID= "booklist2" salePrice= "2"/> > > <Book id= "5" upc= "3" someotherID= "booklist2" salePrice= "3"/> > > <Book id= "6" upc= "4" someotherID= "booklist2" salePrice= "4"/> > > <Book id= "7" upc= "5" someotherID= "booklist2" salePrice= "5"/> > > </BookList> > > </AllBooks> > > > > Thanks > > Alan > > > > > > > > > ________________________________ > > > > > The information contained in this e-mail message is intended only for the > personal and confidential use of the recipient(s) named above. This message > may be an attorney-client communication and/or work product and as such is > privileged and confidential. If the reader of this message is not the > intended recipient or an agent responsible for delivering it to the intended > recipient, you are hereby notified that you have received this document in > error and that any review, dissemination, distribution, or copying of this > message is strictly prohibited. If you have received this communication in > error, please notify us immediately by e-mail, and delete the original > message.
-- Regards, Mukul Gandhi
|
|
 |