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

Is the SAX NamespaceSupport class broken?

  • From: Elliotte Rusty Harold <elharo@m...>
  • To: sax-devel@l...
  • Date: Sun, 14 Oct 2001 18:24:53 -0700

sax namespacesupport
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. However, it seems to 
have a pretty bad design flaw. According to the documentation,

"Normally, you should push a new context at the beginning of each XML 
element: the new context will automatically inherit the declarations of 
its parent context, but it will also keep track of which declarations 
were made within this context."

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. If I declare 
my prefix here, then it will belong to the wrong context for the parent 
of the element where the namespace is declared rather than the element 
where it actually is declared.

Am I missing something here? This seems pretty broken. There are a 
number of workarounds such as declaring a new context for each prefix 
mapping rather than each element, or storing the list of prefixes 
declared in each elements in still another list from 
startPrefixMapping() and then applying them in startElement(). 
Nonetheless, this really feels like a design flaw.


-- 
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@m... | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|               Java I/O (O'Reilly & Associates, 1999)               |
|            http://www.ibiblio.org/javafaq/books/javaio/            |
|   http://www.amazon.com/exec/obidos/ISBN=1565924851/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      | 
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+



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.