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

David Megginson (ak117@freenet.carleton.ca)
Sun, 4 Jan 1998 13:28:12 -0500


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 http://myhost.com/doc.xml:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE doc SYSTEM "http://yourhhost.com/gendoc.dtd">
<doc>
[...]
</doc>

Now, within the DTD, at http://yourhost.com/gendoc.dtd", 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

http://myhost.com/stylesheet.xsl

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

http://yourhost.com/stylesheet.xsl

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

-- 
David Megginson                 ak117@freenet.carleton.ca
Microstar Software Ltd.         dmeggins@microstar.com
      http://home.sprynet.com/sprynet/dmeggins/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ To (un)subscribe, mailto:majordomo@ic.ac.uk the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)