Re: Combining Multiple XML Documents

Subject: Re: Combining Multiple XML Documents
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 28 Jun 2000 20:10:25 +0100
John Greek wrote:
>Yes, but, can you have a xsl stylesheet applied to one of these "entitied"
>files and produce another xml file that consists of the original files
>together (xml + xml) --[xsl]--> xml  :

When you use entities to give the content of an XML file, then it is
treated in exactly the same way as if the XML file held the content of
those entities.  

I'm just going to amend John's combined XML document to avoid confusion:

<!DOCTYPE apage [
 <!ENTITY banner SYSTEM "authors.xml">
 <!ENTITY content SYSTEM "plants.xml">

The two amendments were firstly to add a document element - every XML
document needs one - and secondly to reference the entities within it.
Without the references they are not included: it is not enough just to
define the entities. 

This is exactly the same as:


and you can write an XSLT stylesheet that will process it in just the same
way, so to get a non-well-formed XML document containing the contents of
authors.xml and plants.xml, you can do:

<xsl:template match="authors-and-plants">
  <xsl:copy-of select="*" />

If, however, you are just using the entities as a way of identifying the
files that you want to combine, a cleaner solution might be to list the
files within the XML document, and use document() to access them within
XML.  For example:

  <file href="authors.xml" />
  <file href="plants.xml" />


<xsl:template match="filelist">
  <xsl:for-each select="document(file/@href)">
    <xsl:copy-of select="*" />



Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx

 XSL-List info and archive:

Current Thread