[XML-SIG] clarification request about Sax/Sax2 mappings

Lars Marius Garshol larsga@garshol.priv.no
09 May 2001 18:23:57 +0200

* Alexandre Fayolle
| Specifically, my understanding is that the prototype of the startElement
| method of the ContentHandler interface in Sax2 is supposed to take 4
| arguments (nsUri, localName, qName, attributes). 

This is not correct. In SAX 2.0 there are two startElement methods:

  startElement(name, attributes)
  startElementNS(name, qname, attributes)

In the latter, name is a (nsuri, localname) tuple.

| However, in xml.sax.handler, ContentHandler's startElement method
| has the same prototype as xml.sax.saxlib's DocumentHandler (which
| should be used with a SAX 1 parser), i.e. name, attributes.
That is correct. This is used when the XML processor is not in
namespace mode.

| I'm trying to write a parser for a non-xml document, that should behave as
| a sax parser for the external world, especially to the various DOM reader
| classes available around here. Some of these seem to be expecting calls to
| startElementNS (I'm thinking specifically of FT's pDomletteReader), with
| a signature similar to Java's SAX2 ContentHandler.startElement method.

A good DOM builder should accept calls to both startElement and
startElementNS. It should also require applications to be consistent
and only use one or the other throughout a single document.

I hope this helps.

--Lars M.