[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Merging xml files

Subject: RE: Merging xml files
From: ADAM PATRICK <adampatrick@xxxxxxxxxxxxxx>
Date: Tue, 9 Aug 2005 14:56:02 +0100 (BST)
merge xml doc
thanks to mike for the tip the correct xsl if anyone
is interested...

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	version="1.0">
	
<xsl:output indent="yes"/>
<xsl:template match="ctt">
	<ctt>
		<xsl:variable name="docs"
select="document(./doc/@filename)"/>
		<xsl:for-each select="$docs">
			<xsl:copy-of select="./ctt/ctt_doc"/>
		</xsl:for-each>
	</ctt>
</xsl:template>
</xsl:stylesheet>

--- Michael Kay <mike@xxxxxxxxxxxx> wrote:

> select="./ctt_doc" should be select="./ctt/ctt_doc".
> The document() function
> selects the root node of the document, which is the
> parent of the outermost
> element.
> 
> Michael Kay
> http://www.saxonica.com/ 
> 
> > -----Original Message-----
> > From: ADAM PATRICK
> [mailto:adampatrick@xxxxxxxxxxxxxx] 
> > Sent: 08 August 2005 18:14
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  Merging xml files
> > 
> > Using Instant Saxon 6.5.3
> > 
> > I have seen previous posts but a bit comfounded at
> > getting it to work for me... want to merge
> identical
> > xml files using xslt
> > 
> > the following is what I have so far...any help on
> what
> > my stylesheet should be would be gratefully
> received,
> > thaks.
> > 
> > ctt.xml
> > 
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <ctt>
> > <doc filename="test1.xml"/>
> > <doc filename="test2.xml"/>
> > <doc filename="test3.xml"/>
> > </ctt>
> > 
> > test1.xml - all xml files have the same format
> > 
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <ctt>
> > <ctt_doc ctt_doc_ref="1">
> > <parent_doc_ref>testthis</parent_doc_ref>
> > </ctt_doc>
> > </ctt>
> > 
> > bad xslt stylesheet...(i.e. not working)
> > 
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <xsl:stylesheet
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >  version="1.0">
> >  
> > <xsl:output indent="yes"/>
> > <xsl:template match="ctt">
> >  <ctt>
> >   <xsl:variable name="docs"
> > select="document(ctt/doc/@filename)"/>
> >   <xsl:for-each select="$docs">
> >    <xsl:copy-of select="./ctt_doc"/>
> >    <xsl:copy-of
> select="ctt/ctt_doc/parent_doc_ref"/>
> >   </xsl:for-each>
> >  </ctt>
> > </xsl:template>
> > </xsl:stylesheet>
> > 
> > current output upon:
> >  saxon -o newtest.xml ctt.xml merge.xsl
> > 
> > <?xml version="1.0" encoding="utf-8"?>
> > <ctt/>
> > 
> > would like...
> > 
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <ctt>
> > <ctt_doc ctt_doc_ref="1">
> > <parent_doc_ref>testthis</parent_doc_ref>
> > </ctt_doc>
> > <ctt_doc ctt_doc_ref="2">
> > <parent_doc_ref>testthis</parent_doc_ref>
> > </ctt_doc>
> > <ctt_doc ctt_doc_ref="3">
> > <parent_doc_ref>testthis</parent_doc_ref>
> > </ctt_doc>
> > </ctt>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.