SAX: External Entity Start and End (question 2 of 10)

David Megginson ak117 at
Sun Jan 4 18:33:11 GMT 1998

Tim Bray writes:

 > - one of my goals for SAX is to present to people who want to see XML
 >   as "just elements and attributes".  I happen to think this is a 
 >   reasonable way to want to look at XML; present entities as an
 >   *authoring* convenience; from the point of view of the downstream
 >   parser, your handy local XML parser makes the issue go away

In principle, I agree with you entirely -- the job of an XML parser is
to present a document as a single, logical structure, regardless of
its physical layout, and physical features like entities should have
no place in SAX (except possibly in the case of entity resolution).

As James has pointed out, however, the problem comes with the fact
that many people are proposing the use of URI's instead of entities
for external references.  For example, imagine that I have a simple
XML document, with no external entities except for the external DTD
subset, at the location

 <?xml version="1.0" standalone="no"?>

Now, within the DTD, at", the following
PI appears:

  <?foo source="stylesheet.xsl"?>

How do I resolve this relative URI?  If I use the URI of the document
root, then I will get

However, the DTD designer almost certainly intended this to resolve to

The only way that I can resolve this correctly is if I know the URI of
the current external entity.  In Lark, you provide this information
with a separate Entity argument to each callback; this is a legitimate
(and more powerful) option, but from the perspective of SAX, it ends
up complicating the entire API instead of just adding two
easily-ignored callbacks.

All the best,


David Megginson                 ak117 at
Microstar Software Ltd.         dmeggins at

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as:
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list