Re: Merging two documents

Subject: Re: Merging two documents
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 21 Sep 1999 17:16:45 +0300
At 99/09/20 19:02 -0700, Terris wrote:
Do you think using document() is superior to
concatenating the two documents first?

Absolutely!


For example, the following XML document
would be created:

<ConcatenatedDocument>

  <DocumentA>
    <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>
  </DocumentA>

  <DocumentB>
    <BookList>
      <Book id="1"/>
      <Book id="2"/>
   </BookList>
  </DocumentB>

</ConcatenatedDocument>

In your specific example above there would probably be no problems, but what if both documents had attributes declared as ID attributes?


What if there were an element in each document that happened by coincidence to have the same unique identifier?

Using document() allows you to still access both documents, but access the unique identifiers found in both documents without the risk of collision. My examples earlier showed how using <xsl:for-each> with the document() function allows you to access the ID space within each document independently.

If both documents, each with the same ID in use, were merged into one, it couldn't be validated (because of duplicate IDs) and the id() function of XSLT would at best only find one and at worst report the duplicate ID as an error and refuse to execute.

Of course this isn't a problem if you aren't using IDs, but I assumed you were asking about the general case.

I hope this helps.

............ Ken


-- 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


Current Thread