OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   External parsed general entities (was [xml-dev] so many options no idea

[ Lists Home | Date Index | Thread Index ]

At 2002-07-31 11:16 -0700, Rick Jones wrote:
>"G. Ken Holman" wrote:
> > Personally, I'm a big fan of external parsed general entities for the
> > management of a single large XML document in many small pieces.  My
> > training material is authored in XML and to change one paragraph I need
> > only pull a lesson entity into a text editor instead of the entire course.
>So, when I want the great big config file, don't try to stitch it
>together with statements inside the config file, but "cat" (as it were)
>several  smaller files together - with an XSLT? (probably have the wrong

Nope ... external parsed general entities are pulled together automatically 
by the XML processor to create a single instance.

An external parsed general entity is declared as in:

   <!ENTITY abc SYSTEM "def/abc.ent">

An external parsed general entity is included by reference in an XML 
fragment as in:


The XML processor inside of an XSLT processor worries about finding the 
external parsed general entities, so nothing explicit has to be done by the 
user of the XML document.

> > I do *not* use such constructs for sharing information as fragments between
> > multiple XML instances; I use XSLT to extract fragments of an XML document,
> > thus keeping every external parsed general entity in a single parsing
> > context (set of DTD declarations for entities).

When I want to extract a fragment from another file, XSLT brings that file 
into its internal XPath node tree representation (the XML processor finding 
however many external parsed general entities the author of that file may 
have chosen to use ... it doesn't impact the activity because it is 
automatic) when I use the document() function to make my way to the piece 
that I need.

Had I improperly (though I admit intuitively) just referred to a given 
external parsed general entity from multiple XML files (each having their 
own DTD declarations of entities), then I run a real risk of shooting 
myself in the foot and don't know it until long after the system is 
deployed.  Consider someone modifying their DTD with a new entity and then 
adding a reference to that entity in the shared fragment.  It works fine 
for them.  *Every* other XML document referring to the fragment is now not 
even well-formed and won't even make it to first base in an XSLT process or 
any XML-based application.

In my practice of keeping each of my external parsed general entities to a 
single XML document with its DTD declarations of all entities needed for 
that document, I have the freedom to change the parsing context (set of 
entity declarations) at any time without jeopardizing my environment.

Something I have done a number of places in my environment is edit one 
large XML file in three separate files, the wrapper file being very short:

    <!DOCTYPE document-element
    <!ENTITY entity-with-a-bunch-of-IDed-elements SYSTEM "...uri...">
    <!ENTITY entity-with-a-bunch-of-IDREF-attributes SYSTEM "...uri...">

Each file has its own revision history in my source code control system so 
I can follow the history of changes in one part of the document separate 
from the history of changes in another part of the document.  This has been 
very useful.

I confess a drawback of this approach is that very few XML editing tools 
(perhaps none?) preserve the physical entity structure of using external 
parsed general entities ... so I just use emacs or a non-XML-aware editor 
for my work.

I find when teaching XSLT that very very few students have ever heard of, 
let alone use, external parsed general entities in the management of large 
instances: less than a handful in all of the students of the 57 deliveries 
of my XSLT course I've given around the world since February 1999.  I've 
asked in every course.

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

Upcoming hands-on in-depth 3-days XSLT/XPath and/or 2-days XSL-FO:
-                               North America:  Sep 30-Oct  4,2002
-                               Japan:          Oct  7-Oct 11,2002

G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1                Practical Formatting Using XSLFO
XSL/XML/DSSSL/SGML/OmniMark services, books (electronic, printed),
articles, training (instructor-live,Internet-live,web/CD,licensed)
Next public training:           2002-08-05,26,27,09-30,10-03,07,10


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS