[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Fwd: Combing two different documents
On 7/17/06, andrew welch <andrew.j.welch@xxxxxxxxx> wrote:
On 7/17/06, David B <daavidb@xxxxxxxxx> wrote: > Hello, > > I am trying to combine to seperate XML documents that have the same > structure but different leaf nodes, e.g: > ---File 1.xml--- > <base> > <foo> > <bar1>123</bar1> > </foo> > </base> > --File 2.xml---- > <base> > <foo> > <bar2>abc</bar2> > </foo> > </base> > > I want the output to be: > <base> > <foo> > <bar1>123</bar1> > <bar2>abc</bar2> > </foo> > </base> > > Preferably without hardcoding too much of the structure of the file > into the .xsl.
<xsl:template match="*[*[not(*)]]"> <xsl:copy> <xsl:copy-of select="*"/> <xsl:copy-of select="$file2//*[*[not(*)]][count(preceding::*) = count(current()/preceding::*)]/*"/> </xsl:copy> </xsl:template> If there is mixed content at the level above (<foo> level) use copy-of select="node()", but if all your text nodes are contained by leaf nodes then this should be fine. cheers andrew
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|