[XML-SIG] sax parsing and namespaces

Lars Marius Garshol larsga@garshol.priv.no
16 Nov 2001 12:02:57 +0100


* Alexandre Fayolle
| 
| It looks like the SIG has chosen to tweak the java SAX2
| ContentHandler to have both startElement and startElementNS. While
| this ease the transition from SAX1 to SAX2, needing to write both
| callbacks can cause code duplication.

During a single parse the parser will only call one of these methods,
never both. Some general tools may need to implement both, but in
those cases calling a third method from startElement* will generally
solve the problem of duplication.

| Is there a way of being sure that some XmlReader instance will call
| startElement or startElementNS.

It depends on the http://xml.org/sax/features/namespaces, as you note.
If it's true startElementNS is called, otherwise startElement is
called. There should never ever be any mixing. 

| In other words, does, for instance, setting the
| http://xml.org/sax/features/namespaces feature to TRUE guarantee that
| startElementNS will be called (and not startElement). Is it a bug for an
| instance of XmlReader to do otherwise?

Yes, it is.

--Lars M.