You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Gary L Peskin <ga...@firstech.com> on 2001/08/16 17:57:12 UTC

Re: Namespace feature using a SAX parser with JAXP.

Jean-Guillaume --

Yes.  There is a compatability problem here.  The SAX default for
namespace awareness to true while the JAXP default is false, even for a
SAX parser.

Add the line 

  factory.setNamespaceAware(true);

before your call to

  factory.newSAXParser();

Gary

jean-guillaume.battaglia@inexware.fr wrote:
> 
> Hi.
> 
> On David Megginson page titled "SAX2 Namespace Support", I've read
> this:
> 
> 2. Configuration
> 
> 2.1. Configuring Namespace Support
> 
> The "http://xml.org/features/namespaces" feature controls general
> Namespace processing: when this feature is true (the default),
> Namespace URIs and local names must be available through the
> startElement and endElement callbacks in the ContentHandler interface,
> and through the various methods in the Attributes interface, and
> start/endPrefixMapping events must be reported.
> 
> 
> 
> This means the default value for the
> "http://xml.org/features/namespaces" feature should be true.
> 
> When I instantiate my SAXParser "directly" using the following code :
> 
> XMLReader myReader =
> XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
> 
> I can check that the following code :
> myReader.getFeature("http://xml.org/sax/features/namespaces") returns
> "true".
> 
> That seems correct.
> 
> 
> 
> But when I use JAXP like this :
> 
> SAXParserFactory factory = SAXParserFactory.newInstance();
> 
> SAXParser saxParser = factory.newSAXParser();
> 
> XMLReader myReader = saxParser.getXMLReader();
> 
> I can check that saxParser.isNamespaceAware() or
> myReader.getFeature("http://xml.org/sax/features/namespaces") both
> return false.
> 
> Is it normal ?
> 
> If it is, why isn't JAXP (or maybe xerces implementation of
> SAXParserFactory) respecting SAX2 specification ?
> 
> 
> 
> Thanks.
> 
> 
> Jean-Guillaume.
> 
> P.S. : I hope I didn't make a mistake sending this question to the
> "general mailing-list" but I think the answer could be of some
> interest for different kind of projects.
> 
> ---------------------------------------------------------------------
> 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

---------------------------------------------------------------------
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