[jdom-interest] Namespace issues, et al.
Elliotte Rusty Harold
elharo at metalab.unc.edu
Sun Feb 23 04:59:21 PST 2003
At 1:35 AM -0800 2/22/03, Malachi de AElfweald wrote:
>Ok, I have just started using Schemas and Namespaces.... As such, I
>am running into some problems. Looking at the list, it appears that
>Namespace problems are very common with JDOM, so I thought someone
>(Elliotte?) might be able to shed some light on these issues.
No, namespace problems are very common with XML. One a developer
straightens out their problems with namespaces in XML, they typically
have no problems with namespaces in JDOM.
>Section 6.2 (please read that section before insisting that I am
>misreading it) states that namespaces get retained within scope.
>Specifically, it explains (and SHOWS) that child elements keep the
>same namespace of the parent element unless otherwise specified.
>Also, it states that attributes use the same namespace as the
>enclosing element, unless stated otherwise.
No, no, no. Both claims are wrong, though the attribute claim is more
wrong than the element claim. I don't know what you're looking at,
but there is no section 6.2. Section 5.2 states, and I quote, "the
default namespace does not apply to attribute names"
>Now, before we go further, those two items seem to be the root cause
>of most of the namespace problems I read on the list and experienced
>myself. If you glanced over the last paragraph, reread it.
>
>>From that, I understand the following:
><tagA xmlns="http://www.eoti.org">
> <tagB attrC="hello"/>
></tagA>
>
>In that section of XML, according to section 6.2 of that spec, it
>states that tagA, tagB, and attrC are all in the http://www.eoti.org
>default namespace.
tagA and tagB are. attrC isn't.
>Am I misreading the spec? I did notice that XMLOutputter is
>automatically defaulting
>to version="1.0" on the XMLDecl. Perhaps I am trying to use XML 1.1
>and JDOM is only XML 1.0?
JDOM is only XML 1.0. There is as yet no XML 1.1. Maybe one day there
will be, but that day is not today.
>I would prefer some constructive comments on this issue, because for
>all of my encouragement for the use of JDOM in the workplace,
>without meeting the specification I will not be able to convince the
>employeer to use it. Currently, they are using Apache's stuff on
>the C-side, and are more likely to enforce I use Apache's API
>directly instead of JDOM if JDOM can't deliver.
Your confusion derives from a deep misunderstanding of namespaces in
XML. Yes, namespaces are poorly designed and confusing. No, we didn't
invent them. Once you understand namespaces in XML, then maybe you'll
understand how and why JDOM works the way it does; but as long as you
persist in believing things about namespaces that simply aren't true,
you're going to be confused.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| Processing XML with Java (Addison-Wesley, 2002) |
| http://www.cafeconleche.org/books/xmljava |
| http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list