[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Re: Merging multiple xmls into a single xml


Subject: Re: [xsl] Re: Merging multiple xmls into a single xml
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 25 Jul 2005 12:22:03 -0400

Hi At 02:24 PM 7/22/2005, iwantto keepanon wrote:
See Example 1 "parsed entities" @ http://www.topxml.com/code/default.asp?
p=3&id=v20030524142328&ms=20&l=xslt&sw=All

Basically this is your XML:
   <?xml version="1.0" encoding="utf-8"?>
   <!DOCTYPE allproducts [
      <!ENTITY resourceA SYSTEM "ProductSalesSW.xml">
      <!ENTITY resourceB SYSTEM "ProductSalesNW.xml">
   ]>
   <allproducts>
      &resourceA;
      &resourceB;
   </allproducts>

And this could be your XSLT:
<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>


   <xsl:template match="/">
      <xsl:apply-templates />
   </xsl:template>

   <xsl:template match="allproducts">
      <xsl:element name="products" >
         <xsl:copy-of select="." />
      </xsl:element>
   </xsl:template>

</xsl:stylesheet>

(full listings, discussion, and XML input files at URL.)

You could write a small quick CGI (bash, perl, anything) to generate
the XML file based on files/directories.  Then the XSLT script would
take it from there w/o document() function calls.

My question to the list is, why hasnt this been offered as a solution
to several recent queries like "how do i combine .... ?".  Is this a
good solution?

It's not a bad solution -- and it has been offered, though not recently, and though in answer to a slightly different question. See http://www.biglist.com/lists/xsl-list/archives/200411/msg01016.html.


The reason it's not the *best* answer is probably that it's insufficiently general. Due to a weakness in XML's design -- differences in definition between a "document" and a "well-formed external parsed general entity" -- it won't work in all cases; in particular, you won't be able to do it when any "subdocuments" have DOCTYPE declarations.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


Current Thread
Keywords