xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary L Peskin <ga...@firstech.com>
Subject Re: Namespace feature using a SAX parser with JAXP.
Date Thu, 16 Aug 2001 15:57:12 GMT
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


Mime
View raw message