You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Tomas Studva <ts...@gmail.com> on 2007/10/06 15:43:04 UTC

ElemApplyTemplates implementation

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.

I have some questions about Xalan implementation details. As I 
understand every template element has execute method, which is called to 
execute template element including children (direct). But sometimes 
there is a difference.
1,
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);
                                                transformer
                                                                
.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?)

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?

Thanks for help, Xalan fan :) Tomas Studva






---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org