[jdom-interest] First pass at Namespace revision[eg]
Elliotte Rusty Harold
elharo at metalab.unc.edu
Fri Mar 30 14:12:39 PST 2001
I haven't completely digested all the discussion yet, but Jason did
want me to comment. This use case fails to convince me. Specifically
what bothers me is the indicated part below:
At 1:12 PM +0200 3/29/01, Jochen Strunk wrote:
>We are using jdom in the context of a web framework. Different parts
>of the application deliver parts of an xml document. The framework
>then assembles these parts, assigning each a unique namespace to
>avoid conflicts.
>
>To do this we need the following use case to be supported and I was
>wondering if you think jdom should provide support for this kind of
>use.
>
>Consider having an element which outputs like this:
>
><element>
> <child1 />
> <child2 />
></element>
>
>to achieve this, I need to do the following:
>
>Element element = new Element("element");
>Element child1 = new Element("child1");
>Element child2 = new Element("child2");
>
>element.addContent(child1);
>element.addContent(child2);
>
>This is very straightforward.
>Now I want to change the element so it outputs like this:
>
><element xmlns="http://foo">
> <child1 />
> <child2 />
></element>
>
^^^^^^^^^^^^^^^
Why do you want to change this element like this? Why didn't you just
create it that way in the first place? i.e.:
Element element = new Element("element", "http://foo");
Element child1 = new Element("child1", "http://foo");
Element child2 = new Element("child2", "http://foo");
To convince me you'll also need to demonstrate that you do recognize
that the two element structures you've created are quite different,
and not at all the same thing; and that this is indeed what you want.
And finally you'll need to convince me that this is a common need, so
that the benefit of adding the setNamespace() method for you
outweighs the complexity and misconceptions it will generate in many
other users.
A lot of work and thought has gone into making the JDOM API reflect
the natural structure of XML documents. This means that if you're
using XML the way it was intended to be used, the JDOM approach seems
quite natural. However if you have misconceptions about how XML
works, e.g. you think that an attribute of an element is in the same
namespace as the element is, then JDOM will seem quite difficult. But
what you're really encountering is a problem with XML, not with JDOM.
--
+-----------------------+------------------------+-------------------+
| 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