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


Help: OASIS Mailing Lists Help | MarkMail Help



   Mod??SAX: Feature Matrix

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

It would be interesting to put together a feature matrix representing
current practice among SAX parsers/drivers, at least in the Java
world.  Assuming that I simply wrapped the existing drivers with a
Mod??Parser adapter, what features would and would not be supported?

>From my fuzzy recollection, here's what AElfred supported just about a 
year ago before I gave it up:

                                 true              false
validation                       no                yes
external-general-entities        yes               no
external-parameter-entities      yes               no
namespaces                       no                yes
normalize-text                   yes               no
use-locator                      yes               no

(Wherever there's a 'no' answer, the driver should throw a
SAXNotSupportedException).  Actually, it would probably be safe to
accept false for 'normalize-text' as well.  If I were to wrap the
AElfred driver, then, I'd do something like this (there's likely some
kind of a static initialisation trap here, but it should be good
enough as an unreliable example):

public class AElfredModParser extends com.microstar.xml.SAXDriver
                              implements org.xml.sax.ModParser
  private static Hashtable featureTable = new Hashtable();
  private static final Object TRUE = new Object();
  private static final Object FALSE = new Object();
  private static final Object TRUEFALSE = new Object();
  private static final String FEATURE_NS = "http://xml.org/sax/features/";

  static {
    featureTable.put(FEATURE_NS + "validation", FALSE);
    featureTable.put(FEATURE_NS + "external-general-entities", TRUE);
    featureTable.put(FEATURE_NS + "external-parameter-entities", TRUE);
    featureTable.put(FEATURE_NS + "namespaces", TRUE);
    featureTable.put(FEATURE_NS + "normalize-text", TRUEFALSE);
    featureTable.put(FEATURE_NS + "use-locator", TRUE);

  public void setFeature (String featureID, boolean state)
    throws SAXNotSupportedException
    Object allowedState = featureTable.get(featureID);
    if (allowedState == null) {
      throw new SAXNotRecognizedException();
    } else if ((state && allowedState == FALSE) ||
               (!state && allowedState == TRUE)) {
      throw new SAXNotSupportedException();

  // etc. for setHandler, set, and get

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