SAX2: Namespace Processing and NSUtils helper class

Clark C. Evans clark.evans at manhattanproject.com
Thu Dec 16 09:05:40 GMT 1999


This is very interesting....

On Thu, 16 Dec 1999, Ray Waldin wrote:
> I'm only a user of SAX and not an implementor, but I've always 
> expected SAX 2 to include namespace scoping events.  It seems 
> a bit restrictive to completely hide these events from
> an application.  For example:
> 
> <element1 xmlns="uri1" xmlns:p2="uri2">
>   <ns2:element2 foo="bar" xmlns:p3="uri3" p3:whiz="bang"/>
> </element1>

I assume you mean "p2" instead of "ns2" ?

> would produce the following stream of events:
> 
>   startDocument();
>   startNamespace( prefix=null, uri="uri1" );
>   startNamespace( prefix="p2", uri="uri2" );
>   startElement( name="element1", attrList=null );
>   startNamespace( prefix="p3", uri="uri3" );
>   startElement( name="p2:element2", attrList={ foo="bar", p3:whiz="bang" });
>   endElement( name="p2:element2" )
>   endNamespace( prefix="p3" );
>   endElement( name="element1" );
>   endNamespace( prefix="p2" );
>   endNamespace( prefix="p1" );
>   endDocument();
> 

Slight problem.

The namespaces are defined *after* the element
tag begins.  So, startNamespace would logically
be *inside* of the element like:

startDocument()
  startElement(name="element1" attributes="{...}" )
    defineNamespace(prefix=null, uri="uri1");
     ...

However, attributes (since they are random
and not sequential access), occur within
the event scope of the element.  Yet, the
namespace applies to the attribute!

I realise you put the events immediately
preceding the begin tag and immediately 
following the end tag to get around this
problem, but it just doesn't look pretty.

However, your suggestion would work perfectly
for the 100% pure sequential access interface
which JClark has for native expat !

Best,

Clark 









xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list