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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   John Cowan's view on SAX extensions for ns drafts

[ Lists Home | Date Index | Thread Index ]
  • From: John Cowan <cowan@locke.ccil.org>
  • To: XML Dev <xml-dev@ic.ac.uk>
  • Date: Tue, 11 Aug 1998 14:12:38 -0400

Since I can't be at Montreal, here's my (lengthy, but hopefully
complete) proposal for extending SAX 1.0.  My design goals are:

    o	Supports current ns draft
    o	Conceptually compatible with David Megginson's XML-Dev
	    message of 8 August
    o	Equally useful for integral or layered implementations
    o	Fully backward compatible with SAX 1.0

1. A new optional application-side interface to allow applications to
intercept, record, and decode namespace scope events:

	public interface NamespaceHandler {
	    public void startNamespaceScope (String prefix, String URI,
			NamespaceResolver resolver);
	    public void endNamespaceScope (String prefix);
	}

The startNamespaceScope event is called when a namespace comes into
scope, and the endNamespaceScope event when the namespace goes out of
scope.  The NamespaceResolver objects passed in distinct calls to
startNamespaceScope may or may not be distinct objects.

Multiple namespace scopes may be declared by a single element.
The order of events is:

	DocumentHandler.startElement,
	NamespaceHandler.startNamespaceScope (may be repeated),
	[events within scope]
	NamespaceHandler.endNamespaceScope (may be repeated),
	DocumentHandler.endElement.

It is an error if the URI is the null string and prefix is *not* the
null string.

2. A new standard SAX class (not an interface) for representing
UniversalNames:

	public class UniversalName {
	    private String _URI;
	    private String _localPart;
	    public UniversalName(String URI, String localPart) {
		_URI = URI; _localPart = localPart;
	    }
	    public String getURI () {return _URI;}
	    public String getLocalPart () {return _localPart;}
	    public long hashCode () {
		return _URI.hashCode() ^ _localPart.hashCode();
	    }
	    public boolean equals (Object object) {
		if (object instanceof UniversalName) {
		    UniversalName other = (UniversalName) object;
		    return _URI.equals(other._URI) &&
			_localPart.equals(other._localPart);
		}
		else return false;
	    }
        }

This is a class so that it can have a standard constructor.  Either
parsers or applications can create UniversalName objects.

3. A new optional parser-side interface for resolving qualified names:

	public interface NamespaceResolver {
	    public static final String INTERNAL_XML_URI = "x-xml:xml";
	    public static final String INTERNAL_XMLNS_URI = "x-xml:xmlns";

	    public void setNamespaceHandler (NamespaceHandler handler);
	    public UniversalName resolveElementName (String name)
		throws SAXException;
	    public UniversalName resolveAttributeName (String name,
		UniversalName elementName)
		throws SAXException;

	    public String getType (AttributeList attlist,
		UniversalName name);
	    public String getValue (AttributeList attlist,
		UniversalName name);
	}

To declare an interest in namespaces, an application implements
NamespaceHandler and calls NamespaceResolver.setNamespaceHandler.

By convention, a parser implements NamespaceResolver if and only
if it is namespace-aware.  (This does not necessarily mean that
the NamespaceResolver objects passed to the NamespaceHandler are
== to the parser object.)

NamespaceResolver objects are valid from the time
NamespaceHandler.startNamespaceScope is called until the matching
call to NamespaceHandler.endNamespaceScope.

Applications can resolve an element name passed to
DocumentHandler.{start,end}Element into universal form by calling
resolveElementName.  If there is no prefix, the resulting UniversalName
has an URI that is null.

Applications can resolve an attribute name retrieved from
AttributeList.getName into universal form by calling
resolveAttributeName.  The UniversalName of the element to which this
attribute belongs is required so that the URI can be defaulted from
the element if there is no prefix on the attribute.

If a prefix is "xml" or "xmlns", and there has been no definition of
these prefixes, then the URI is == to INTERNAL_XML_URI or
INTERNAL_XMLNS_URI respectively.  A SAXException is thrown if the prefix
is otherwise undefined.

The getType and getValue methods are convenience methods that allow
an application to search a currently available AttributeList object
using a UniversalName.

Comments?

-- 
John Cowan	http://www.ccil.org/~cowan		cowan@ccil.org
	You tollerday donsk?  N.  You tolkatiff scowegian?  Nn.
	You spigotty anglease?  Nnn.  You phonio saxo?  Nnnn.
		Clear all so!  'Tis a Jute.... (Finnegans Wake 16.5)

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)





 

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

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