Re: [xsl] DOM and XPath Data Model

Subject: Re: [xsl] DOM and XPath Data Model
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 19 Jun 2003 09:34:47 -0600 (MDT)
Fatih TURKMEN wrote:
> I just wonder how XSLT processors handle differences
> between XPath Data model and DOM.In fact, my question
> is which one is more common XPath engines operate on
> XPath Data model or DOM (in which no need of making
> mapping between DOM and XPath data model).XSLT
> generates a DOM tree(result) and XPath expressions are
> evaluated on XPath Data model so some kind of
> transformations are needed.Am I right?

XPath and XSLT use the same data model, which is DOM-like, but is not the same
as the DOM data model (e.g., DOM has more types of nodes and stores attribute
values differently), and is not necessarily implemented internally as a DOM
object. XSLT processors are only required to produce output (well, they aren't
even required to output anything) as if they had acted on the XPath/XSLT data
model, regardless of what the actual implementation used internally or what it
used for input and output.

Also, DOM is just an object-oriented API that implies an underlying data
model; there's no requirement that node objects actually exist -- an
implementation is just required to act as if they do :)

Furthermore, DOM contains a lot of things that are not needed in XPath or XSLT
processing. If an XSLT processor were to maintain fully Level I compliant DOM
objects for the source trees, stylesheet tree, result tree fragments, and
result tree, then there would likely be much waste and needless data being
stored. Of course, this overhead can vary depending on things such as the
efficiency of the programming language involved, but even so, processing a 1
MB serialized XML document typically requires 10 to 50 MB of memory just to
model the document itself, let alone transform it.

Michael Kay further describes these issues and discusses related optimizations
in his article "Saxon: Anatomy of an XSLT Processor" at
http://www-106.ibm.com/developerworks/library/x-xslt2/ and IIRC the
documentation for Saxon contains some good info as well.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread