RE: [xsl] Combining two XML files into one

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