зеркало из https://github.com/mozilla/gecko-dev.git
introduce XSLTProcessor::processChildren which is a slimmed down version of XSLTProcessor::processTemplate to avoid checking for xsl:param elements where it's not needed. bug 77830. r=peterv,pike sr=jst a=asa(on behalf of drivers)
This commit is contained in:
Родитель
b3c6959aa9
Коммит
5f9114479f
|
@ -24,7 +24,7 @@
|
|||
* Tom Kneeland, tomk@mitre.org
|
||||
* -- added UInt32 to provide a common unsigned integer
|
||||
*
|
||||
* $Id: baseutils.h,v 1.6 2001/01/12 20:06:09 axel%pike.org Exp $
|
||||
* $Id: baseutils.h,v 1.7 2001/06/15 11:12:14 sicking%bigfoot.com Exp $
|
||||
*/
|
||||
|
||||
// Basic Definitions used throughout many of these classes
|
||||
|
@ -38,6 +38,20 @@ typedef int Int32;
|
|||
typedef unsigned int UInt32;
|
||||
#endif
|
||||
|
||||
#ifdef TX_EXE
|
||||
|
||||
#ifdef DEBUG
|
||||
#define NS_ASSERTION(_cond, _msg) \
|
||||
if(!(_cond)) { \
|
||||
cerr << "ASSERTION (" << #_cond << ") " << _msg << endl; \
|
||||
cerr << "on line " << __LINE__ << " in " << __FILE__ << endl; \
|
||||
}
|
||||
#else
|
||||
#define NS_ASSERTION(_cond, _msg) {}
|
||||
#endif
|
||||
|
||||
#endif //TX_EXE
|
||||
|
||||
typedef Int32 MBool;
|
||||
|
||||
#define MB_TRUE (MBool)1
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
/**
|
||||
* XSLTProcessor is a class for Processing XSL stylesheets
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.51 $ $Date: 2001/06/10 16:41:19 $
|
||||
* @version $Revision: 1.52 $ $Date: 2001/06/15 11:12:17 $
|
||||
**/
|
||||
|
||||
/**
|
||||
|
@ -978,7 +978,7 @@ void XSLTProcessor::processAction
|
|||
if ( newAttr ) {
|
||||
DocumentFragment* dfrag = resultDoc->createDocumentFragment();
|
||||
ps->getNodeStack()->push(dfrag);
|
||||
processTemplate(node, actionElement, ps);
|
||||
processChildren(node, actionElement, ps);
|
||||
ps->getNodeStack()->pop();
|
||||
String value;
|
||||
XMLDOMUtils::getNodeValue(dfrag, &value);
|
||||
|
@ -1036,13 +1036,13 @@ void XSLTProcessor::processAction
|
|||
expr = ps->getExpr(xslTemplate->getAttribute(TEST_ATTR));
|
||||
ExprResult* result = expr->evaluate(node, ps);
|
||||
if ( result->booleanValue() ) {
|
||||
processTemplate(node, xslTemplate, ps);
|
||||
processChildren(node, xslTemplate, ps);
|
||||
caseFound = MB_TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XSLType::OTHERWISE:
|
||||
processTemplate(node, xslTemplate, ps);
|
||||
processChildren(node, xslTemplate, ps);
|
||||
caseFound = MB_TRUE;
|
||||
break;
|
||||
default: //-- invalid xsl:choose child
|
||||
|
@ -1057,7 +1057,7 @@ void XSLTProcessor::processAction
|
|||
{
|
||||
DocumentFragment* dfrag = resultDoc->createDocumentFragment();
|
||||
ps->getNodeStack()->push(dfrag);
|
||||
processTemplate(node, actionElement, ps);
|
||||
processChildren(node, actionElement, ps);
|
||||
ps->getNodeStack()->pop();
|
||||
String value;
|
||||
if (!getText(dfrag, value, MB_FALSE,MB_TRUE)) {
|
||||
|
@ -1127,7 +1127,7 @@ void XSLTProcessor::processAction
|
|||
node, ps);
|
||||
}
|
||||
//-- process template
|
||||
processTemplate(node, actionElement, ps);
|
||||
processChildren(node, actionElement, ps);
|
||||
if( element ) ps->getNodeStack()->pop();
|
||||
}
|
||||
break;
|
||||
|
@ -1165,7 +1165,7 @@ void XSLTProcessor::processAction
|
|||
//-- push nodeSet onto context stack
|
||||
ps->getNodeSetStack()->push(nodeSet);
|
||||
for (int i = 0; i < nodeSet->size(); i++) {
|
||||
processTemplate(nodeSet->get(i), xslAction, ps);
|
||||
processChildren(nodeSet->get(i), actionElement, ps);
|
||||
}
|
||||
//-- remove nodeSet from context stack
|
||||
ps->getNodeSetStack()->pop();
|
||||
|
@ -1187,7 +1187,7 @@ void XSLTProcessor::processAction
|
|||
|
||||
ExprResult* exprResult = expr->evaluate(node, ps);
|
||||
if ( exprResult->booleanValue() ) {
|
||||
processTemplate(node, actionElement, ps);
|
||||
processChildren(node, actionElement, ps);
|
||||
}
|
||||
delete exprResult;
|
||||
|
||||
|
@ -1200,7 +1200,7 @@ void XSLTProcessor::processAction
|
|||
|
||||
DocumentFragment* dfrag = resultDoc->createDocumentFragment();
|
||||
ps->getNodeStack()->push(dfrag);
|
||||
processTemplate(node, actionElement, ps);
|
||||
processChildren(node, actionElement, ps);
|
||||
ps->getNodeStack()->pop();
|
||||
XMLDOMUtils::getNodeValue(dfrag, &message);
|
||||
delete dfrag;
|
||||
|
@ -1246,7 +1246,7 @@ void XSLTProcessor::processAction
|
|||
}
|
||||
DocumentFragment* dfrag = resultDoc->createDocumentFragment();
|
||||
ps->getNodeStack()->push(dfrag);
|
||||
processTemplate(node, actionElement, ps);
|
||||
processChildren(node, actionElement, ps);
|
||||
ps->getNodeStack()->pop();
|
||||
String value;
|
||||
if (!getText(dfrag, value, MB_FALSE,MB_TRUE)) {
|
||||
|
@ -1389,11 +1389,7 @@ void XSLTProcessor::processAction
|
|||
}
|
||||
}
|
||||
//-- process children
|
||||
Node* tmp = xslAction->getFirstChild();
|
||||
while (tmp) {
|
||||
processAction(node,tmp,ps);
|
||||
tmp = tmp->getNextSibling();
|
||||
}
|
||||
processChildren(node, actionElement,ps);
|
||||
ps->getNodeStack()->pop();
|
||||
#ifndef TX_EXE
|
||||
if ( newDefaultNS ) {
|
||||
|
@ -1515,6 +1511,29 @@ NamedMap* XSLTProcessor::processParameters(Element* xslAction, Node* context, Pr
|
|||
return params;
|
||||
} //-- processParameters
|
||||
|
||||
/**
|
||||
* Processes the children of the specified element using the given context node
|
||||
* and ProcessorState
|
||||
* @param node the context node
|
||||
* @param xslElement the template to be processed. Must be != NULL
|
||||
* @param ps the current ProcessorState
|
||||
**/
|
||||
void XSLTProcessor::processChildren(Node* node, Element* xslElement, ProcessorState* ps) {
|
||||
|
||||
NS_ASSERTION(xslElement,"xslElement is NULL in call to XSLTProcessor::processChildren!");
|
||||
|
||||
Stack* bindings = ps->getVariableSetStack();
|
||||
NamedMap localBindings;
|
||||
localBindings.setObjectDeletion(MB_TRUE);
|
||||
bindings->push(&localBindings);
|
||||
Node* child = xslElement->getFirstChild();
|
||||
while (child) {
|
||||
processAction(node, child, ps);
|
||||
child = child->getNextSibling();
|
||||
}
|
||||
bindings->pop();
|
||||
} //-- processChildren
|
||||
|
||||
/**
|
||||
* Processes the specified template using the given context, ProcessorState, and actual
|
||||
* parameters.
|
||||
|
@ -1624,14 +1643,10 @@ ExprResult* XSLTProcessor::processVariable
|
|||
return expr->evaluate(node, ps);
|
||||
}
|
||||
else {
|
||||
Node* tmpNode = xslVariable->getFirstChild();
|
||||
Document* resultTree = ps->getResultDocument();
|
||||
NodeStack* nodeStack = ps->getNodeStack();
|
||||
nodeStack->push(resultTree->createDocumentFragment());
|
||||
while (tmpNode) {
|
||||
processAction(node, tmpNode, ps);
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
processChildren(node, xslVariable, ps);
|
||||
Node* node = nodeStack->pop();
|
||||
//-- add clean up for This new NodeSet;
|
||||
NodeSet* nodeSet = new NodeSet();
|
||||
|
@ -1651,7 +1666,7 @@ void XSLTProcessor::xslCopy(Node* node, Element* action, ProcessorState* ps) {
|
|||
switch ( node->getNodeType() ) {
|
||||
case Node::DOCUMENT_NODE:
|
||||
//-- just process children
|
||||
processTemplate(node, action, ps);
|
||||
processChildren(node, action, ps);
|
||||
break;
|
||||
case Node::ELEMENT_NODE:
|
||||
{
|
||||
|
@ -1687,7 +1702,7 @@ void XSLTProcessor::xslCopy(Node* node, Element* action, ProcessorState* ps) {
|
|||
processAttributeSets(action->getAttribute(USE_ATTRIBUTE_SETS_ATTR), copy, ps);
|
||||
|
||||
//-- process template
|
||||
processTemplate(node, action, ps);
|
||||
processChildren(node, action, ps);
|
||||
ps->getNodeStack()->pop();
|
||||
#ifndef TX_EXE
|
||||
if ( newDefaultNS ) {
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
/**
|
||||
* A class for Processing XSL Stylesheets
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.20 $ $Date: 2001/06/10 16:41:51 $
|
||||
* @version $Revision: 1.21 $ $Date: 2001/06/15 11:12:18 $
|
||||
**/
|
||||
class XSLTProcessor
|
||||
#ifndef TX_EXE
|
||||
|
@ -325,6 +325,15 @@ private:
|
|||
void processAttrValueTemplate
|
||||
(const String& attValue, String& result, Node* context, ProcessorState* ps);
|
||||
|
||||
/**
|
||||
* Processes the children of the specified element using the given context node
|
||||
* and ProcessorState
|
||||
* @param node the context node
|
||||
* @param xslElement the template to be processed. Must be != NULL
|
||||
* @param ps the current ProcessorState
|
||||
**/
|
||||
void processChildren(Node* node, Element* xslElement, ProcessorState* ps);
|
||||
|
||||
void processTemplate(Node* node, Node* xslTemplate, ProcessorState* ps, NamedMap* actualParams = NULL);
|
||||
void processTemplateParams(Node* xslTemplate, Node* context, ProcessorState* ps, NamedMap* actualParams);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче