You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by be...@marketing.net.uk on 2001/07/20 13:08:25 UTC

Crimson 1.1.1 / SAX2 reporting namespace-less element names as qName rather than localName

Hi,

I'm curious about the behaviour of Crimson 1.1.1 when used as a SAX2
XMLReader.  For some reason, for XML elements with no namespace, the name
is returned as the qName parameter to startElement(), rather than localName
as expected; localName is empty.  We're hoping for flexibility in changing
parsers (hence the move to 1.1.1 for the better JAXP support), so we'd like
to acheive consistent behaviour if at all possible.  Is there any way of
getting Crimson to comply with SAX2 on this?

Regards,
Ben Pickering






---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Crimson 1.1.1 / SAX2 reporting namespace-less element names as qName ratherthan localName

Posted by Edwin Goei <ed...@sun.com>.
benp@marketing.net.uk wrote:
> 
> Hi,
> 
> I'm curious about the behaviour of Crimson 1.1.1 when used as a SAX2
> XMLReader.  For some reason, for XML elements with no namespace, the name
> is returned as the qName parameter to startElement(), rather than localName
> as expected; localName is empty.  We're hoping for flexibility in changing
> parsers (hence the move to 1.1.1 for the better JAXP support), so we'd like
> to acheive consistent behaviour if at all possible.  Is there any way of
> getting Crimson to comply with SAX2 on this?

In the javadoc at
http://www.megginson.com/SAX/Java/javadoc/org/xml/sax/ContentHandler.html,
under startElement() it states under Parameters:

    localName - The local name (without prefix), or the empty string if
Namespace processing is not being performed.

If you used crimson 1.1 or the JAXP reference implementation 1.1 before,
did you explicityly turn on namespace processing?  There was a bug in
crimson 1.1 in this area where if you instantiated an XMLReader via
JAXP, the implementation would behave as if namespace processing was on
by default (even though SAXParserFactory#getNamespaceAware() returned
false), but it should have been off to conform to the JAXP spec.  This
was fixed in 1.1.1.

To fix this, you can get the XMLReader instance and call
setFeature(".../namespaces", true) or alternatively call
setNamespaceAware(true) on the SAXParserFactory.  Applications that do
this will then work with all crimson implementations as they will no
longer rely on the default setting.

-Edwin

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org