OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xml-dev] Is the SAX NamespaceSupport class broken?



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@metalab.unc.edu | 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/     |
+----------------------------------+---------------------------------+