[jdom-interest] XSLT and JDOM

Dennis Sosnoski dms at sosnoski.com
Sat Apr 14 12:22:23 PDT 2001

In an offlist discussion the topic of using XSLT with JDOM came up. From my
understanding of XSLT it's designed to generate a new output document from an
input document in a particular manner, generating the output document
sequentially using "random" access to the input document - in other words, XSLT
looks at the components of the input document in no fixed order except as
determined by the actual transformations being applied. In-place transformation
of a document is not a function that XSLT really supports, and it would probably
be very difficult for an XSLT implementation to use in-place transformations.

This being the case, XSLT will work most efficiently with an input document
representation which allows fast and efficient access to nodes in both forward
and reverse document order, both between sibling children and up and down the
ancestor tree. It is not a requirement of XSLT that the document representation
support modifications (other than appending items in document order on the
output side, assuming this is building a representation rather than just writing
text or generating an event stream).

My suggestion for JDOM is that if it is to support efficient XSLT implementation
it needs to take these requirements into account. The current implementation
does well on going up the tree and in moving through the children at a level
(once the list of children has been generated, itself currently a high overhead
operation). It's more awkward for traversing the nodes in document order, which
requires recursing down through levels of the tree and getting the list of
children at each level.

Traversing the nodes also requires iterating through the children at a level in
either forward or reverse order (though forward order is probably used much more
often than reverse order). The proposed change to a SinglyLinkedList
implementation would keep forward iteration efficient but make reverse iteration
very expensive.

I don't claim to be an XSLT expert, but I believe these are valid concerns. If
someone more knowledgeable on XSLT wants to comment I'd appreciate the feedback.

  - Dennis

Dennis M. Sosnoski
Sosnoski Software Solutions, Inc.

More information about the jdom-interest mailing list