Wednesday, September 27, 2006

Seventh son

Only the good die young
All the evil seem to live forever

Iron Maiden - Seventh Son Of A Seventh Son (1988)

Some links:

The hell of NodeList

Probably a more better title could be “The hell of NodeList and a bad boy that doesn’t read the documentation” (with Java 1.5).
Yes, this little thing (reading documentation) is a very good thing if you want to have headaches working with NodeLists.
The summary of this painful lesson is:

  • If you work with an XML document you must remember that:

    The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live. (http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/NodeList.html)

    that is, if you change or remove nodes, your changing and removing directly to the document.

  • But if you work with XPath to evaluate expression and get node references, you must remeber it uses Xalan and the NodeSet class implements the NodeList interface and:

    Note that we directly implement the DOM’s NodeIterator interface. We do not emulate all the behavior of the standard NodeIterator. In particular, we do not guarantee to present a “live view” of the document

    (http://xml.apache.org/xalan-j/apidocs/org/apache/xpath/NodeSet.html)

This means not is the same a NodeList returnes by a getChildNodes() than a NodeList returned by an xpath evaluate() method.

Monday, September 25, 2006

I don't know

Perhaps the most common and greatest thought never thought in the history. Good, ugly or bad, thanks to it, the world has changed a long to the years becoming what it is know.