[XML-SIG] SAX 2.0, again

THOMAS PASSIN tpassin@idsonline.com
Mon, 21 Feb 2000 12:25:29 -0500

Lars Marius Garshol wrote:
> Some weeks ago David Megginson released a SAX 2.0 beta in Java, and
> this release appears to be quite close to the final form of SAX 2.0.
> I've started working on translating this release into Python, but
> there are some general design issues that need to be thought through
> before this can be completed.
> ### XML names
> The first problem is that of how to represent XML names. SAX 2.0 can
> handle namespaces, and so we must somehow represent namespace-names.

I think we should make it as easy as possible to use either namespace-style
names or ordinary names, so both can be used in the same way as far as
possible.  The application shouldn't have to figure out the structure before
it can even extract the value.  So I don't think the xml name should be a
tuple if it has a declared namespace but a string if there is no namespace.

With this in mind, how about


If namespaces were not being used, prefix and uri would be None (or possibly
the empty string).  This allows the use of alternative values for the prefix
(so you could, for example, use xslt:template for xsl:template if you wanted
to, which is the way it is supposed to work), and you could check the uri
value anytime you needed to learn the exact namespace.  localpart would
always be a string.

Also, if you had a document containing several prefixes for the same
namespace, you could easily use the localpart and uri, rather than the

I don't recall how it shook out on XML-DEV, but there were a number of posts
that said it was important to keep the actual prefix value, and this
approach would do that.

BTW, "uri" doesn't actually need to be a uri, any unique string will do.

> I can see several different ways of doing this, all with their
> advantages and disadvantages, and would very much like to hear the
> opinion of the XML-SIG on this.
> The alternatives I've thought of are
>  - use (uri, localpart) tuple for namespace-names, simple strings for
>    ordinary names
>  - use (uri, localpart, rawname) for namespace-names, simple strings
>    for ordinary names; rawname must be communicated out of band
>    somehow
>  - use XMLName objects for names, regardless of kind. If these were
>    made immutable and drivers used hashtables of these this might not
>    be too inefficient.
>  - use separate parameters for uri, localpart and rawname, letting
>    some of these be None depending on what was in the document and
>    what the parser supports.

Tom Passin