Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Firts impressions

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Laurent Bihanic <laurent.bihanic AT atosorigin.com>
  • To: XOM-interest <XOM-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] Firts impressions
  • Date: Thu, 19 Sep 2002 10:33:38 +0200

Neat! The Node interface is a *huge* step forward compared to JDOM and not relying on Iterators makes the implementation code a lot simpler.

Yet there are some issues XOM does not address (in addition to those listed on the site) like:

- ClassLoader issues: Type-safe enumerations, such as Attribute.Type, do not fit well with class loaders, even when implementing equals() (see http://www.javaworld.com/javatips/jw-javatip122_p.html).

- Code compactness: As I already said on the jdom-interest mailing list, there are cases (e.g. TreeNode.getChild()) where instanceof tests make the code very unclear and thus harder to maintain.
I know Elliotte does not like the idea of a int getNodeType() method but we need to find a way to remove these ugly tests.

- CDATA handling: There are cases where I need a tool to edit XML documents that are also edited manually. If a user used a CDATA section, I'd probably like to output the document with a CDATA section. Wouldn't Text.setCDATA(boolean) / isCDATA() be acceptable?

- Document portions: JDOM uses Lists to "model" document portions. Wouldn't XOM need a DocumentFragment node class, for example as a receptacle for XSLT result trees?

- Automatic detach: Having to call detach when moving nodes from one place to another is realy cumbersome. A typical example is sorting a list of children. Why not support an automatic-detach mode so that programmer can move nodes freely?

- Tree walking: XOM should provide classes to ease walking document trees (TreeWalker, Visitor...).

- HTML Serializer, as more and more people use XML input and XSLT to generate HTML pages.

Other small remarks:
- Element.getNamespacePrefix() vs Attribute.getPrefix(): to be made consistent. getNamespacePrefix is clearer.
- Element.add(): Why not addAttribute() as every other attribute- and child-related method names have suffixes (get/read/removeAttribute, append/insertChild, ...).
- Node.howManyChildren(): getChildCount() would have been more intuitive to Java programmers.

My best wishes of success to XOM!

Laurent





Archive powered by MHonArc 2.6.24.

Top of Page