Re: Merging two documents

Subject: Re: Merging two documents
From: "Terris" <terris@xxxxxxxxxx>
Date: Wed, 15 Sep 1999 08:18:36 -0700
Your response is very helpful.

However, for performance
reasons, external files are not good.  I have "temporary"
documents in memory that I would like to process.

Does document() support that or do I have to write
"doc1" out to a file first?  The only solution I can
think of is if document() lets you put the document
inside the quotes instead of a URL.

Or ... if this isn't supported, could I concatenate the
two documents and then "merge" them using one stylesheet?

----- Original Message -----
From: G. Ken Holman <gkholman@xxxxxxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxx>
Sent: Tuesday, September 14, 1999 7:26 PM
Subject: Re: Merging two documents


> At 99/09/14 18:51 -0700, you wrote:
> >Is there a way to embed doc1 inside
> ><xsl:param name="source"> instead of referring to an
> >external document?  I couldn't tell from reading the spec.
>
> You needn't use <xsl:param> to store the name of the external document,
you
> could just use:
>
>            <xsl:for-each select="document('doc1.xml')">
>
> But, that wouldn't be very flexible ... what I've done below is I've made
> "doc1.xml" the *default* if you don't supply one on the command line, but
> you can still override the default if you wish.
>
> I hope this helps.
>
> .............. Ken
>
> p.s. XT can be obtained from http://www.jclark.com/xml/xt.html and there
is
> some additional documentation regarding XT's Non-XML environment in the
> free download preview of XSLT training material available from our web
site
>
>
> T:\ftemp>type doc1.xml
> <?xml version="1.0"?>
> <!DOCTYPE BookSet [
> <!ATTLIST Book id ID #IMPLIED>
> ]>
> <BookSet>
>    <Book id="1"><Name>The wizard of OZ</Name></Book>
>    <Book id="2"><Name>Java Servlet Programming</Name></Book>
>    <Book id="3"><Name>John Coltrane Rage</Name></Book>
> </BookSet>
>
> T:\ftemp>type doc2.xml
> <BookList>
>     <Book id="1"/>
>     <Book id="2"/>
> </BookList>
>
> T:\ftemp>type list.xsl
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0";>
>
> <xsl:output method="xml" indent="yes"/>
>
>   <!--source of data; default can be overridden on command line-->
> <xsl:param name="source" select="'doc1.xml'"/>
>
> <xsl:template match="/BookList">          <!--document element-->
>    <BookList>
>      <xsl:for-each select="Book">
>        <Book id="{@id}">
>          <xsl:variable name="id" select="string(@id)"/>
>             <!--note you cannot use document($source)/id($id)/*-->
>          <xsl:for-each select="document($source)">
>            <xsl:copy-of select="id($id)/*"/>
>          </xsl:for-each>
>        </Book>
>      </xsl:for-each>
>    </BookList>
> </xsl:template>
>
> </xsl:stylesheet>
>
> T:\ftemp>xt doc2.xml list.xsl result.xml
>
> T:\ftemp>type result.xml
> <BookList>
> <Book id="1">
> <Name>The wizard of OZ</Name>
> </Book>
> <Book id="2">
> <Name>Java Servlet Programming</Name>
> </Book>
> </BookList>
>
> T:\ftemp>
>
> --
> G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
> Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/
> Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
> Website:  XSL/XML/DSSSL/SGML services, training, libraries, products.
> Practical Transformation Using XSLT and XPath      ISBN 1-894049-01-2
> Next instructor-led training:  1999-09-24, 1999-11-08, 1999-12-05/06,
>                               1999-12-07, 2000-02-27/28, 2000-05-11/12
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread