开发者

When I parse an XSLT in a context where the input and output are SAX, is a DOM tree created behind the scenes?

Here is example code I am referring to:

http://xml.apache.org/xalan-开发者_运维百科j/usagepatterns.html#sax

First, notice that everything that can be SAX-based is SAX-based in this code: both the input and the output.

Also, notice that a transformerHandler object is created off of "foo.xsl" and that transformerHandler is used to do a transformation from the SAX input to the SAX ContentHandler that creates the output.

I had understood that XSLT requires something like a DOM tree to be built in order for it to do its work.

So here is my question: I wonder if the transformerHandler is actually building something like a DOM tree behind the scenes? If it is, doesn't that kind of defeat the purpose of trying so hard to stay in SAX-land?


Quoting from http://xml.apache.org/xalan-j/dtm.html

The Document Table Model (DTM) is an interface to a Document Model designed specifically for the needs of our XPath and XSLT implementations. The motivation behind this model is to optimize performance and minimize storage.

Specifically, DTM avoids the overhead of instantiating the objects the standard DOM requires to represent a tree of nodes. DTM uses unique integer "handles" to identify nodes, integer ID values to represent URLs, local names, and expanded names, and integer index and length references to a string buffer to represent the text value of each node.

In other words, it doesn't build a DOM tree but it builds an efficient structure that is specially suited to meet the needs of XSLT.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜