[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Importing multiple XML files into one XML file

Subject: Re: Importing multiple XML files into one XML file
From: "Chisanga Mwelwa" <sangz2000@xxxxxxxxxxx>
Date: Wed, 14 Apr 2004 15:46:43 +0000
import multiple xml files
Ken,

I appreciate your help on my previous problem - your solution is working well!

However - I am now trying to recursively import multiple XML files eg:

You previously advised me to use this "structure" - it works fine...

<!-- employees.xml -->
<!DOCTYPE EMPLOYEES
[
<!ENTITY emp-stuff SYSTEM "employee.xml">
]>
<EMPLOYEES>
<OFFICE name="Town Hall">
 &emp-stuff;
</OFFICE>
</EMPLOYEES>

but what I would like to do is extend the entity structure "recursively" - note "dob-stuff" in the example below...

<!-- employee.xml -->
<!DOCTYPE EMPLOYEES
[
<!ENTITY dob-stuff SYSTEM "dob.xml">
]>
<EMPLOYEE>
  <NAME>Jo Blogs</NAME>
  &dob-stuff;
</EMPLOYEE>

... and then

<!-- dob.xml -->
  <DOB>1-12-1980</DOB>

Well I have been trying this (assuming it is possible!) but the Crimson parser doesnt seem to like this I am getting the following error message:

org.xml.sax.SAXParseException: The content beginning "<!" is not legal markup. Perhaps the "!" (&#21;) character should be a letter.

I'm I asking for "too much" with the physical entity structure or is there something I'm not doing correctly?

Your help is once again appreciated!

--Chisanga--



From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Importing multiple XML files into one XML file
Date: Tue, 06 Apr 2004 13:31:36 -0400

At 2004-04-06 16:55 +0000, Chisanga Mwelwa wrote:
I want to use XML as a template for an application data source. Now the problem I have come across is the increasing size of the XML files and I was wondering whether there is an elegant way in which I can organise my files.

Use the physical entity structure available for XML documents and external parsed general entities.


For instance if I have a an XML file such as "employees.xml":

<?--employees.xml-->
<EMPLOYEES>

<OFFICE name="Town Hall">

 <EMPLOYEE>
  <NAME>Jo Blogs</NAME>
  <DOB>1-12-1980</DOB>
 </EMPLOYEE>

</OFFICE>

</EMPLOYEES>

Now say I would like to create another file "employee.xml" and use it to store the data currently in the <EMPLOYEE> tag instead of craming everything into the "employees.xml" file

That would be the external parsed general entity.


and then (I dont know how...) call this file from the main file: "employees.xml" file.

That would be the general entity reference.


Is there a way I could achieve this?

An example is below; I hope this helps.


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

p.s. I use this extensively in my prose writing of my books and training material because it allows me to maintain modules, lessons and frames in separate XML fragments, referenced through a tree of entity references, as separate objects in my source code control system ... I don't have to check out an entire module just to change a single paragraph.

p.p.s. do not be lured into using external parsed general entities for information sharing ... only for the fragmentation of a single large instance into portions ... use the document() function in XSLT for information sharing as the general entity approach is far too fragile to use in a production environment

T:\ftemp>type employees.xml
<!DOCTYPE EMPLOYEES
[
<!ENTITY emp-stuff SYSTEM "employee.xml">
]>
<EMPLOYEES>

<OFFICE name="Town Hall">

&emp-stuff;

</OFFICE>

</EMPLOYEES>

T:\ftemp>type employee.xml
 <EMPLOYEE>
  <NAME>Jo Blogs</NAME>
  <DOB>1-12-1980</DOB>
 </EMPLOYEE>

T:\ftemp>type chisanga.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:template match="@*|node()"><!--identity for all other nodes-->
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>saxon employees.xml chisanga.xsl
<?xml version="1.0" encoding="utf-8"?><EMPLOYEES>

<OFFICE name="Town Hall">

  <EMPLOYEE>
  <NAME>Jo Blogs</NAME>
  <DOB>1-12-1980</DOB>
 </EMPLOYEE>


</OFFICE>


</EMPLOYEES>
T:\ftemp>

--
Public courses: Spring 2004 world tour of hands-on XSL instruction
Each week:   Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO
Hong Kong May 17-21; Bremen Germany May 24-28; Helsinki June 14-18

World-wide on-site corporate, govt. & user group XML/XSL training.
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 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


_________________________________________________________________ Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.