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


Help: OASIS Mailing Lists Help | MarkMail Help



   SAX2: AttributeList2 and EntityRefList

[ Lists Home | Date Index | Thread Index ]
  • From: David Megginson <david@megginson.com>
  • To: "XML Developers' List" <xml-dev@ic.ac.uk>
  • Date: Thu, 25 Mar 1999 09:17:19 -0500 (EST)

While we're polishing the details of LexicalHandler (which may yet
become DocumentHandler2 -- I'm still listening to arguments both
ways), I'd like to propose two new SAX2 support interfaces.


This first interface is designed to work around a *very* nasty problem 
with XML 1.0 conformance, and at the same time, to enable the tracking 
of entity references in attribute values for the few masochists who
care.  As John Cowan has pointed out, the XML 1.0 REC requires that
processors report unexpanded entity references, and presumably that
applies to references in attribute values as well as elsewhere; as a
result, it is impossible to treat an XML attribute value simply as a

On the other hand, almost nobody will every need this, so it's not
worth complicating the interface much for parser writers or for
application writers.

So, after some thought, here's what I came up with.  This is a special 
interface providing indexes to zero or more entity references in a
literal string (i.e. an attribute value).  The indices are based on
whatever array indices the programming language is using, exclusive of 
Unicode problems with combining characters, etc. (i.e. any
normalisation must already have taken place).

// EntityRefList.java - list entity references in an attribute value.

package org.xml.sax;

public interface EntityRefList
    public int getLength ();
    public String getEntityName (int i);
    public int getEntityRefStart (int i);
    public int getEntityRefEnd (int i);

// end of EntityRefList.java

The nice thing is that this lives outside of the String representing
the attribute value, so almost everyone can ignore it, and there
should be no performance hit.  It also provides nice
backwards-compatibility with SAX 1.0.


Here's what I've come up with for lexical attribute information in

// AttributeList2.java - SAX2 extensions for an attribute list

package org.xml.sax;

public interface AttributeList2 extends AttributeList
    public boolean isSpecified (int index);
    public boolean isSpecified (String name);
    public EntityRefList getEntityRefList (int index);
    public EntityRefList getEntityRefList (String name);

// end of AttributeList2.java

This, together with the DTDDeclHandler interface I'll be describing in 
a separate posting, should provide enough information for full DOM
level one core attribute support.

All the best,


David Megginson                 david@megginson.com

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/ and on CD-ROM/ISBN 981-02-3594-1
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)


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

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