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

RE: Combining two XML files into one

Subject: RE: Combining two XML files into one
From: "Karl Koch" <TheRanger@xxxxxxx>
Date: Wed, 20 Jul 2005 22:16:52 +0200 (MEST)
combine 2 xml files
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 +++

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.