[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [Sax-devel] Is the SAX NamespaceSupport class broken?

  • From: David Brownell <david-b@p...>
  • To: Elliotte Rusty Harold <elharo@m...>,sax-devel@l...
  • Date: Sun, 14 Oct 2001 17:16:48 -0700

sax namespacesupport
Quoth: "Elliotte Rusty Harold" <elharo@m...>
> I'd like to use an org.xml.sax.helpers.NamespaceSupport object to keep 
> track of the namesapces in scope at various points in my ContentHandler, 
> which is exactly what I think it's designed to do.

Well, one of its tasks.  It's described as "for use by SAX Drivers",
but the same logic should be used in applications if they are willing
to deal with the quirk you identified:


> OK, simple enough. I need to start a new context for each element. Now I 
> need to add declarations to that context using the declarePrefix() 
> method. However, the information I need to track the declared prefixes 
> are provided by the startPrefixMapping() method, which is called 
> *before* the corresponding startElement() method is called.

I call this a doc bug.  The "you" in the documentation is a parser writer,
for whom it makes a certain degree of sense:  they'll pushContext()
THEN make the startPrefixMapping() callbacks for xmlns* attributes,
then make the second pass over element/attribute names to get the
URIs and localnames, and then finally call startElement().

When the "you" is an application, it's different.  Creating the context
must be done at either of two locations:  startElement(), or else the
first startPrefixMapping().

As David Megginson wrote, the fix is a single flag.  In fact I did a
writeup on NamespaceSupport recently (for a certain SAX2 book :)
where I said exactly that.


I'll provide a fix in the javadoc, and push it out soon after SourceForge
starts talking to me again.  (The SSH services seem to be AWOL this
weekend.)

- Dave



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.