bug 113611, XPath and XSLT contexts. fixes bugs 96410, 102293, 92106, 110266, 116534 and a bunch of other cases not filed. This mostly fixes namespaces and some really bad speed issues by fixing the time when namespaces are resolved, how default priorities are computed and how templates are matched.
HUGE PERFWIN :-) r=peterv, sr=jst git-svn-id: svn://10.0.0.236/trunk@122650 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "XMLDOMUtils.h"
|
||||
#include "Tokenizer.h"
|
||||
#include "txAtom.h"
|
||||
#include "txIXPathContext.h"
|
||||
|
||||
/*
|
||||
* Creates a NodeSetFunctionCall of the given type
|
||||
@@ -75,16 +76,16 @@ NodeSetFunctionCall::NodeSetFunctionCall(NodeSetFunctions aType)
|
||||
* for evaluation
|
||||
* @return the result of the evaluation
|
||||
*/
|
||||
ExprResult* NodeSetFunctionCall::evaluate(Node* aContext, ContextState* aCs) {
|
||||
ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
|
||||
ListIterator iter(¶ms);
|
||||
switch (mType) {
|
||||
case COUNT:
|
||||
{
|
||||
if (!requireParams(1, 1, aCs))
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return new StringResult("error");
|
||||
|
||||
NodeSet* nodes;
|
||||
nodes = evaluateToNodeSet((Expr*)iter.next(), aContext, aCs);
|
||||
nodes = evaluateToNodeSet((Expr*)iter.next(), aContext);
|
||||
if (!nodes)
|
||||
return new StringResult("error");
|
||||
|
||||
@@ -94,11 +95,11 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* aContext, ContextState* aCs) {
|
||||
}
|
||||
case ID:
|
||||
{
|
||||
if (!requireParams(1, 1, aCs))
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return new StringResult("error");
|
||||
|
||||
ExprResult* exprResult;
|
||||
exprResult = ((Expr*)iter.next())->evaluate(aContext, aCs);
|
||||
exprResult = ((Expr*)iter.next())->evaluate(aContext);
|
||||
if (!exprResult)
|
||||
return new StringResult("error");
|
||||
|
||||
@@ -108,11 +109,12 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* aContext, ContextState* aCs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Document* contextDoc;
|
||||
if (aContext->getNodeType() == Node::DOCUMENT_NODE)
|
||||
contextDoc = (Document*)aContext;
|
||||
Document* contextDoc = 0;
|
||||
Node* contextNode = aContext->getContextNode();
|
||||
if (contextNode->getNodeType() == Node::DOCUMENT_NODE)
|
||||
contextDoc = (Document*)contextNode;
|
||||
else
|
||||
contextDoc = aContext->getOwnerDocument();
|
||||
contextDoc = contextNode->getOwnerDocument();
|
||||
|
||||
if (exprResult->getResultType() == ExprResult::NODESET) {
|
||||
NodeSet* nodes = (NodeSet*)exprResult;
|
||||
@@ -123,7 +125,9 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* aContext, ContextState* aCs) {
|
||||
txTokenizer tokenizer(idList);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
tokenizer.nextToken(id);
|
||||
resultSet->add(contextDoc->getElementById(id));
|
||||
Node* idNode = contextDoc->getElementById(id);
|
||||
if (idNode)
|
||||
resultSet->add(idNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,7 +137,9 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* aContext, ContextState* aCs) {
|
||||
txTokenizer tokenizer(idList);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
tokenizer.nextToken(id);
|
||||
resultSet->add(contextDoc->getElementById(id));
|
||||
Node* idNode = contextDoc->getElementById(id);
|
||||
if (idNode)
|
||||
resultSet->add(idNode);
|
||||
}
|
||||
}
|
||||
delete exprResult;
|
||||
@@ -142,30 +148,23 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* aContext, ContextState* aCs) {
|
||||
}
|
||||
case LAST:
|
||||
{
|
||||
if (!requireParams(0, 0, aCs))
|
||||
if (!requireParams(0, 0, aContext))
|
||||
return new StringResult("error");
|
||||
|
||||
NodeSet* contextNodeSet = (NodeSet*)aCs->getNodeSetStack()->peek();
|
||||
if (!contextNodeSet) {
|
||||
String err("Internal error");
|
||||
aCs->recieveError(err);
|
||||
return new StringResult("error");
|
||||
}
|
||||
|
||||
return new NumberResult(contextNodeSet->size());
|
||||
return new NumberResult(aContext->size());
|
||||
}
|
||||
case LOCAL_NAME:
|
||||
case NAME:
|
||||
case NAMESPACE_URI:
|
||||
{
|
||||
if (!requireParams(0, 1, aCs))
|
||||
if (!requireParams(0, 1, aContext))
|
||||
return new StringResult("error");
|
||||
|
||||
Node* node = 0;
|
||||
// Check for optional arg
|
||||
if (iter.hasNext()) {
|
||||
NodeSet* nodes;
|
||||
nodes = evaluateToNodeSet((Expr*)iter.next(), aContext, aCs);
|
||||
nodes = evaluateToNodeSet((Expr*)iter.next(), aContext);
|
||||
if (!nodes)
|
||||
return new StringResult("error");
|
||||
|
||||
@@ -177,7 +176,7 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* aContext, ContextState* aCs) {
|
||||
delete nodes;
|
||||
}
|
||||
else {
|
||||
node = aContext;
|
||||
node = aContext->getContextNode();
|
||||
}
|
||||
|
||||
switch (mType) {
|
||||
@@ -219,21 +218,14 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* aContext, ContextState* aCs) {
|
||||
}
|
||||
case POSITION:
|
||||
{
|
||||
if (!requireParams(0, 0, aCs))
|
||||
if (!requireParams(0, 0, aContext))
|
||||
return new StringResult("error");
|
||||
|
||||
NodeSet* contextNodeSet = (NodeSet*)aCs->getNodeSetStack()->peek();
|
||||
if (!contextNodeSet) {
|
||||
String err("Internal error");
|
||||
aCs->recieveError(err);
|
||||
return new StringResult("error");
|
||||
}
|
||||
|
||||
return new NumberResult(contextNodeSet->indexOf(aContext) + 1);
|
||||
return new NumberResult(aContext->position());
|
||||
}
|
||||
}
|
||||
|
||||
String err("Internal error");
|
||||
aCs->recieveError(err);
|
||||
aContext->receiveError(err, NS_ERROR_UNEXPECTED);
|
||||
return new StringResult("error");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user