[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] SAX2: AttributeList2 and EntityRefList
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. EntityRefList ------------- 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 string. 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). ====================8<====================8<==================== // 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 ====================8<====================8<==================== 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. AttributeList2 -------------- Here's what I've come up with for lexical attribute information in SAX2: ====================8<====================8<==================== // 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 ====================8<====================8<==================== 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 -- David Megginson david@m... http://www.megginson.com/ xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i... 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@i... the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@i... the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@i...)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|