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

RE: RE: Combining two XML files into one

Subject: RE: RE: Combining two XML files into one
From: "Karl Koch" <TheRanger@xxxxxxx>
Date: Wed, 20 Jul 2005 23:11:33 +0200 (MEST)
karl koch
I have modified your stylesheet slightly now, because I also think it is
nicer to have all the information in the stylesheet. Since I actually want
ot merge 15 different files in one run, it don't work with parameters
either...

I have tested it and it seems to work fine. 

Thank you very much,
Karl


> --- Urspr|ngliche Nachricht ---
> Von: cknell@xxxxxxxxxx
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff: RE: RE:  Combining two XML files into one
> Datum: Wed, 20 Jul 2005 16:46:04 -0400
> 
> I was using the first stylesheet to transform kkoch3b.xml. I needed to get
> access to kkoch3a.xml as well. By using the document() function, I could
> get access to a document that was not involved in the transform. The
command
> line for the first stylesheet is:
> 
> java -jar c:\saxon\saxon.jar kkoch3b.xml kkoch3.xslt
> 
> As you can see, there is no reference to kkoch3a.xml on the command line
> (nor, so far as I can tell, can there be), so I had to retrieve it using
the
> document() function.
> 
> The interesting part (to me) of the second stylesheet is that it doesn't
> matter what XML file you pass to the stylesheet on the command line. It is
> ignored by the stylesheet. All the processing is directed to the two XML
> files whose names are passed as parameters to the two instances of the
> document() function.
> 
> 
> -- 
> Charles Knell
> cknell@xxxxxxxxxx - email
> 
> 
> 
> -----Original Message-----
> From:     Karl Koch <TheRanger@xxxxxxx>
> Sent:     Wed, 20 Jul 2005 22:16:52 +0200 (MEST)
> To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  RE:  Combining two XML files into one
> 
> Thank you for the quick response and fixing my mistakes. Why did you only
> use kkoch3a in the first stylesheet? 
> 
> Actually I do not need sorting, but thank you for providing it anyway.
> 
> Thank you very much - I am testing it right now,
> Karl
> 
> 
> > --- Urspr|ngliche Nachricht ---
> > Von: cknell@xxxxxxxxxx
> > An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Betreff: RE:  Combining two XML files into one
> > Datum: Wed, 20 Jul 2005 16:09:10 -0400
> > 
> > After fixing the xml, the solution is to use the document() function.
> The
> > bookshelf elements had two opening tags and no closing tag, and the book
> > elements had nothing resembling a closing tag. 
> > 
> > I saved one file as kkoch3a.xml and the other as kkoch3b.xml. The first
> > stylesheet works if the books are in sorted order already. The second
> style
> > sheet sorts them if that is what you want and they are not already in
> the
> > sort order you wish to have.
> > 
> > -- no sorting --
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >   <xsl:output method="xml" indent="yes" encoding="UTF-8" />
> >   <xsl:strip-space elements="*" />
> >   <xsl:variable name="kkoch3a" select="document('kkoch3a.xml')" />
> > 
> >   <xsl:template match="/">
> >     <xsl:apply-templates />
> >   </xsl:template>
> > 
> >   <xsl:template match="bookshelf">
> >     <bookshelf>
> >       <xsl:apply-templates select="$kkoch3a/bookshelf/book" />
> >       <xsl:apply-templates />
> >     </bookshelf>
> >   </xsl:template>
> > 
> >   <xsl:template match="book">
> >     <xsl:copy-of select="." />
> >   </xsl:template>
> > 
> > </xsl:stylesheet>
> > 
> > -- sorting --
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >   <xsl:output method="xml" indent="yes" encoding="UTF-8" />
> >   <xsl:strip-space elements="*" />
> >   <xsl:variable name="kkoch3a" select="document('kkoch3a.xml')" />
> >   <xsl:variable name="kkoch3b" select="document('kkoch3b.xml')" />
> > 
> >   <xsl:template match="/">
> >     <xsl:call-template name="sort-books" />
> >   </xsl:template>
> > 
> >   <xsl:template name="sort-books">
> >     <bookshelf>
> >       <xsl:for-each select="$kkoch3a/bookshelf/book |
> > $kkoch3b/bookshelf/book">
> >         <xsl:sort select="title" />
> >         <xsl:apply-templates select="." />
> >       </xsl:for-each>
> >     </bookshelf>
> >   </xsl:template>
> > 
> >   <xsl:template match="book">
> >     <xsl:copy-of select="." />
> >   </xsl:template>
> > 
> > </xsl:stylesheet>
> > -- 
> > Charles Knell
> > cknell@xxxxxxxxxx - email
> > 
> > 
> > 
> > -----Original Message-----
> > From:     Karl Koch <TheRanger@xxxxxxx>
> > Sent:     Wed, 20 Jul 2005 21:29:02 +0200 (MEST)
> > To:       "Mulberry list" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> > Subject:   Combining two XML files into one
> > 
> > Hello all,
> > 
> > how can I combine two XML files into one assuming that I have the same
> > structre in both files like this:
> > 
> > (The first file)
> > 
> > <bookshelf>
> >   <book><title>1st Book</title>
> >   <book><title>2nd Book</title>
> >   <book><title>3rd Book</title>
> > <bookshelf>
> >  
> > (The second file)
> > 
> > <bookshelf>
> >   <book><title>4th Book</title>
> >   <book><title>5th Book</title>
> >   <book><title>6th Book</title>
> > <bookshelf>
> > 
> > 
> > I wouild like to have the following file:
> > 
> > <bookshelf>
> >   <book><title>1st Book</title>
> >   <book><title>2nd Book</title>
> >   <book><title>3rd Book</title>
> >   <book><title>4th Book</title>
> >   <book><title>5th Book</title>
> >   <book><title>6th Book</title>
> > <bookshelf>
> > 
> > Is this possible? If yes, how can I do that? I am using SAXON. 
> > 
> > Kind Regards,
> > Karl
> > 
> > -- 
> > 5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
> > +++ GMX - die erste Adresse fo?=r Mail, Message, More +++
> > 
> 
> -- 
> 5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
> +++ GMX - die erste Adresse fo?=r Mail, Message, More +++
> 

-- 
GMX DSL = Maximale Leistung zum minimalen Preis!
2000 MB nur 2,99, Flatrate ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl

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.