[jdom-interest] First pass at Namespace revision[eg]

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Apr 4 05:53:33 PDT 2001

>James Duncan Davidson wrote:

>>  For setName()/space() -- these methods *should* be added to the API. The
>>  use case for this is data manipulation from one XML doc to another with
>>  the same elements/data. Say I've got a servlet receiving content from
>>  the web in XML and I'm going to write it to disk, but first I want to
>>  change it to my own thoughts of what the XML should be -- if I can't use
>>  a setName, then I have to do XSLT -- way too much overhead for something
>>  so simple -- especially if I've already got the data in JDOM.
>I believe this is a strong use case: basically a translation tool for
>when XSLT just isn't worth the trouble (or the overhead).

Maybe. I'm still not convinced. It seems plausible but

1. Is anyone actually doing this?

2. This is exactly what XSLT is designed to do, and I don't 
necessarily believe that XSLT has too much overhead here. Certainly 
if I were faced with this problem my inclination would be to toss an 
XSLT processor into the pipeline. I think for anyone equally skilled 
in JDOM and XSLT, the XSLT alternative would be simpler and more 
robust. Side note: adding these methods would not really help you to 
develop an XSLT processor in JDOM, because XSLT builds a separate 
result tree from the input tree. It does not change an existing tree.

3. Based on the previously suggested use cases, I strongly suspect 
that by far the most common uses of setName() and setNamespace() will 
not be for this plausible use case, but for other problems that 
really should not be solved by saetName() and setNamespace(). I'm 
worried that we're going to end up with something like the mess CDATA 
sections have become in XML, where they're used for everything except 
what they were actually meant to be used for, and consequently end up 
polluting an otherwise very clean model.

4. Every setter method you add makes thread safety that much trickier.

Still, the use case seems prima facie plausible. So the real question 
is, do the benefits of adding these methods outweigh the recognized 
downsides or not?

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |

More information about the jdom-interest mailing list