Tomas Studva wrote:
Hi,
I am developing an incremental(not in meaning as is Xalan) XSLT
processor called
Darwin(http://tstudva.googlepages.com/darwin-anincrementalxsltprocessor),
based on Xalan trunk.

...
In ElemApplyTemplates when matching node against template there is code
case DTM.TEXT_NODE:
                                               // if(rth.m_elemIsPending ||
                                               // rth.m_docPending)
                                               // rth.flushPending(true);
                                               transformer

.pushPairCurrentMatched(
sroot
.getDefaultTextRule(),
child);
.setCurrentElement(sroot
.getDefaultTextRule());
                                               //
dtm.dispatchCharactersEvents(child,
                                               // chandler,
false);

dtm.dispatchCharactersEvents(
                                                               child, rth,
                                                               false);

transformer.popCurrentMatched();
                                               continue;

There is some default template, sroot.getDefaultTextRule(), but it is
not executed and instead direct call to
dtm.dispatchCharactersEvents(child, rth,false); is performed.
Why?(optimization?)
Probably, because the default text rule would just dispatch the characters event. Xalan-C has a similar optimization.


2, In ElemApplyTemplates after template is found, is set on stacks and
so on and params are processed, follows code with comment
// And execute the child templates.
// Loop through the children of the template,
// calling execute on
// each of them.
for (ElemTemplateElement t = template.m_firstChild; t != null; t =
t.m_nextSibling) {
                                       xctxt.setSAXLocator(t);
                                       try {
                                               transformer

.pushElemTemplateElement(t);
                                               t.execute(transformer,
null);
                                       } finally {
                                               transformer

.popElemTemplateElement();
                                       }
                               }
which directly executes children of matched template insted of executing
template. Why?
You would have to trace through the alternate code path to figure this out, but perhaps it's an optimization as well. Someone who is more familiar with Xalan-J might know better.

If you have any knowledge of C++, you might want to look at Xalan-C, which implements an iterative stylesheet execution model. With some limitations, it could easily be adapted to an incremental model, since the execution could be interrupted with each "child" that is instantiated.

One major limitation is that the evaluation of params and variables is not executed iteratively. Instead, they are executed recursively, because I'm not quite sure what the semantics of iteratively executing the evaluation of the params would be.

Dave

Reply via email to