[jdom-interest] The JDOM Model, Chapter 15 of Processing XML
with Java
Elliotte Rusty Harold
elharo at metalab.unc.edu
Tue May 7 08:22:38 PDT 2002
At 10:57 AM -0400 5/7/02, Alex Rosen wrote:
>with the content is much simpler. But 5% of the time you do care, and we
>lose this information. The question is, is it worth it to make JDOM easier
>in the 95% case if that eliminates its use for 5% of your projects?
I'm particularly worried about the cases where JDOM is incorrect for
5% of the documents in a project, as opposed to 5% of the projects.
Worse yet: 0.5% or 0.05% because these might not get caught in
testing.
There's a very popular fallacy among developers that says "All
documents in my project adhere to a schema, perhaps implicitly." In
other words, the developer knows in advance which features of XML are
and are not used in the documents they're processing. They know in
advance which elements appear where and what they contain. They know
what attributes they can count on, etc. Barring explicit validation
before processing, this simply isn't true. Documents do contain
elements they aren't supposed to contain. Attributes that are
supposed to be integers have unexpected white space in the middle.
Required elements are missing. This happens all the time.
In fact, it's nothing new in XML. Lots of software like Microsoft
Word crashes because somebody fed it a document that contains a
structure the programmers "knew" couldn't happen and thus didn't
check for. Never trust your input. What's useful about XML is that it
makes verification much easier.
Interestingly XSLT/XPath take a slightly different approach to this
problem. They are designed to be robust in the face of unexpected and
missing content. That's one reason I'm so fond of the XPath 1.0 data
model.
>Should
>JDOM become just a Java developer's view of XML, warts and all? Is that
>enough of an improvement over DOM to make JDOM worthwhile?
>
Absolutely. DOM is still a mess, mostly due to the need to be a
cross-language API. We don't suffer from that constraint.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (Hungry Minds, 2001) |
| http://www.cafeconleche.org/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/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