dbertoni 01/07/08 11:40:09
Modified: c/src/XPath XPath.hpp XPath.cpp SimpleNodeLocator.hpp
SimpleNodeLocator.cpp
Log:
More efficient match score implementation.
Revision Changes Path
1.26 +73 -96 xml-xalan/c/src/XPath/XPath.hpp
Index: XPath.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.hpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- XPath.hpp 2001/06/27 18:26:09 1.25
+++ XPath.hpp 2001/07/08 18:40:07 1.26
@@ -68,6 +68,10 @@
+#include <PlatformSupport/DoubleSupport.hpp>
+
+
+
// Base class header files...
#include <XPath/XPathExecutionContext.hpp>
@@ -80,7 +84,6 @@
class PrefixResolver;
-class XLocator;
class XObject;
class XalanNode;
@@ -127,13 +130,10 @@
terminate();
/**
- * Construct an XPath and optionally a default locator
- *
- * @param createDefaultLocator true to create a default locator object,
- * default true
+ * Construct an XPath.
*/
explicit
- XPath(bool createDefaultLocator = true);
+ XPath();
virtual
~XPath();
@@ -141,7 +141,7 @@
/**
* Shrink internal tables.
*/
- virtual void
+ void
shrink();
/**
@@ -152,7 +152,7 @@
* @param executionContext current execution context
* @return pointer to union of node-set operands
*/
- virtual const XObjectPtr
+ const XObjectPtr
execute(
XalanNode* context,
const PrefixResolver& prefixResolver,
@@ -167,13 +167,21 @@
* @param executionContext current execution context
* @return pointer to union of node-set operands
*/
- virtual const XObjectPtr
+ const XObjectPtr
execute(
XalanNode* context,
const PrefixResolver& prefixResolver,
const NodeRefListBase& contextNodeList,
- XPathExecutionContext& executionContext) const;
+ XPathExecutionContext& executionContext) const
+ {
+ // Set and restore the context node list...
+ XPathExecutionContext::ContextNodeListSetAndRestore
theSetAndRestore(
+
executionContext,
+
contextNodeList);
+ return execute(context, prefixResolver, executionContext);
+ }
+
/**
* Execute the XPath from the provided context. The
* prefix resolver must already be set in the
@@ -182,9 +190,14 @@
* @param executionContext current execution context
* @return pointer to result XObject
*/
- virtual const XObjectPtr
- execute(XPathExecutionContext& executionContext) const;
+ const XObjectPtr
+ execute(XPathExecutionContext& executionContext) const
+ {
+ assert(executionContext.getPrefixResolver() != 0);
+ return executeMore(executionContext.getCurrentNode(), 0,
executionContext);
+ }
+
/**
* Execute the XPath from the provided context.
*
@@ -193,7 +206,7 @@
* @param executionContext current execution context
* @return pointer to union of node-set operands
*/
- virtual const XObjectPtr
+ const XObjectPtr
executeMore(
XalanNode* context,
int opPos,
@@ -207,7 +220,7 @@
* @param executionContext current execution context
* @return node-set
*/
- virtual const XObjectPtr
+ const XObjectPtr
locationPath(
XalanNode* context,
int opPos,
@@ -234,73 +247,57 @@
{
return m_expression;
}
-
-#if defined(XALAN_INLINE_INITIALIZATION)
- /**
- * The match score if no match is made.
- */
- const double s_MatchScoreNone =
-9999999999999.0;
-
- /**
- * The match score if the pattern has the form
- * of a QName optionally preceded by an @ character.
- */
- const double s_MatchScoreQName = 0.0;
-
- /**
- * The match score if the pattern has the form NCName:*.
- */
- const double s_MatchScoreNSWild =
-0.25;
-
- /**
- * The match score if the pattern consists of just a NodeTest.
- */
- const double s_MatchScoreNodeTest =
-0.5;
-
- /**
- * The match score if the pattern consists of something
- * other than just a NodeTest or just a qname.
- */
- const double s_MatchScoreOther = 0.5;
-#else
- /**
- * The match score if no match is made.
- */
- static const double
s_MatchScoreNone;
- /**
- * The match score if the pattern has the form
- * of a QName optionally preceded by an @ character.
- */
- static const double
s_MatchScoreQName;
-
- /**
- * The match score if the pattern has the form NCName:*.
- */
- static const double
s_MatchScoreNSWild;
+ enum eMatchScore
+ {
+ eMatchScoreNone,
+ eMatchScoreNodeTest,
+ eMatchScoreNSWild,
+ eMatchScoreQName,
+ eMatchScoreOther
+ };
- /**
- * The match score if the pattern consists of just a NodeTest.
- */
- static const double
s_MatchScoreNodeTest;
+ static double
+ getMatchScoreValue(eMatchScore score)
+ {
+ switch(score)
+ {
+ case eMatchScoreNone:
+ return DoubleSupport::getNegativeInfinity();
+ break;
+
+ case eMatchScoreNodeTest:
+ return -0.5;
+ break;
+
+ case eMatchScoreNSWild:
+ return -0.25;
+ break;
+
+ case eMatchScoreOther:
+ return 0.5;
+ break;
+
+ case eMatchScoreQName:
+ return 0.0;
+ break;
+ };
- /**
- * The match score if the pattern consists of something
- * other than just a NodeTest or just a qname.
- */
- static const double
s_MatchScoreOther;
-#endif
+ assert(false);
+ return 0.0;
+ }
/**
- * Computes the union of its operands which must be node-sets.
+ * Get the match score for the specified node.
*
- * @param context current source tree context node
+ * @param node The node for the score
+ * @param resolver The prefix resolver
* @param executionContext current execution context
* @return union of node-set operands
*/
- virtual double
+ eMatchScore
getMatchScore(
- XalanNode* context,
+ XalanNode* node,
const PrefixResolver& resolver,
XPathExecutionContext& executionContext) const;
@@ -312,7 +309,7 @@
* @param executionContext current execution context
* @return pointer to either a boolean or a number
*/
- virtual const XObjectPtr
+ const XObjectPtr
predicate(
XalanNode* context,
int opPos,
@@ -323,7 +320,7 @@
*
* @param targetStrings vector of strings
*/
- virtual void
+ void
getTargetElementStrings(TargetElementStringsVectorType&
targetStrings) const;
/**
@@ -422,7 +419,7 @@
/**
* createXLocatorHandler.
*/
- virtual XLocator*
+ XLocator*
createXLocatorHandler() const;
/**
@@ -431,7 +428,7 @@
* @param opPos The current position in the m_opMap array.
* @return the match score in the form of an XObject.
*/
- virtual const XObjectPtr
+ const XObjectPtr
matchPattern(
XalanNode* context,
int opPos,
@@ -463,7 +460,7 @@
doGetMatchScore(
XalanNode* context,
XPathExecutionContext& executionContext,
- double& score) const;
+ eMatchScore& score) const;
/**
* OR two expressions and return the boolean result.
@@ -658,18 +655,6 @@
XPathExecutionContext& executionContext) const;
/**
- * Cast an expression to a number.
- * @param context The current source tree context node.
- * @param opPos The current position in the m_opMap array.
- * @return arg cast to a number.
- */
- const XObjectPtr
- number(
- XalanNode* context,
- int opPos,
- XPathExecutionContext& executionContext) const;
-
- /**
* Computes the union of its operands which must be node-sets.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
@@ -819,14 +804,6 @@
};
// Data members...
-
- /**
- *
- * The default XLocator to use if a custom one is not
- * available.
- *
- */
- XLocator*
m_defaultXLocator;
/**
*
1.57 +26 -99 xml-xalan/c/src/XPath/XPath.cpp
Index: XPath.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- XPath.cpp 2001/06/29 18:47:56 1.56
+++ XPath.cpp 2001/07/08 18:40:08 1.57
@@ -88,8 +88,7 @@
-XPath::XPath(bool createDefaultLocator) :
- m_defaultXLocator(createDefaultLocator == false ? 0 :
createXLocatorHandler()),
+XPath::XPath() :
m_expression(),
m_inStylesheet(false)
{
@@ -130,25 +129,7 @@
-XLocator*
-XPath::createXLocatorHandler() const
-{
- return SimpleNodeLocator::getDefaultInstance();
-}
-
-
-
const XObjectPtr
-XPath::execute(XPathExecutionContext& executionContext) const
-{
- assert(executionContext.getPrefixResolver() != 0);
-
- return executeMore(executionContext.getCurrentNode(), 0,
executionContext);
-}
-
-
-
-const XObjectPtr
XPath::execute(
XalanNode* context,
const PrefixResolver& prefixResolver,
@@ -163,25 +144,8 @@
XPathExecutionContext::CurrentNodeSetAndRestore
theNodeSetAndRestore(
executionContext,
context);
-
- return execute(executionContext);
-}
-
-
-const XObjectPtr
-XPath::execute(
- XalanNode* context,
- const PrefixResolver& prefixResolver,
- const NodeRefListBase& contextNodeList,
- XPathExecutionContext& executionContext) const
-{
- // Push and pop the PrefixResolver...
- XPathExecutionContext::ContextNodeListSetAndRestore
theSetAndRestore(
-
executionContext,
-
contextNodeList);
-
- return execute(context, prefixResolver, executionContext);
+ return executeMore(context, 0, executionContext);
}
@@ -266,10 +230,6 @@
return boolean(context, opPos, executionContext);
break;
- case XPathExpression::eOP_NUMBER:
- return number(context, opPos, executionContext);
- break;
-
case XPathExpression::eOP_UNION:
return Union(context, opPos, executionContext);
break;
@@ -329,21 +289,19 @@
XPath::doGetMatchScore(
XalanNode* context,
XPathExecutionContext& executionContext,
- double& score) const
+ eMatchScore& score) const
{
assert(context != 0);
int opPos = 2;
- XLocator* const locator = m_defaultXLocator;
-
while(m_expression.m_opMap[opPos] ==
XPathExpression::eOP_LOCATIONPATHPATTERN)
{
const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
- score = locator->locationPathPattern(*this, executionContext,
*context, opPos);
+ score = SimpleNodeLocator::locationPathPattern(*this,
executionContext, *context, opPos);
- if(score == s_MatchScoreNone)
+ if(score == eMatchScoreNone)
{
opPos = nextOpPos;
}
@@ -356,23 +314,24 @@
-double
-XPath::getMatchScore(XalanNode* context,
- const PrefixResolver&
resolver,
- XPathExecutionContext&
executionContext) const
+XPath::eMatchScore
+XPath::getMatchScore(
+ XalanNode* node,
+ const PrefixResolver& resolver,
+ XPathExecutionContext& executionContext) const
{
- double score = s_MatchScoreNone;
+ eMatchScore score = eMatchScoreNone;
if(m_expression.m_opMap[0] == XPathExpression::eOP_MATCHPATTERN)
{
- assert(context != 0);
+ assert(node != 0);
const PrefixResolver* const theCurrentResolver =
executionContext.getPrefixResolver();
if (theCurrentResolver == &resolver)
{
- doGetMatchScore(context, executionContext, score);
+ doGetMatchScore(node, executionContext, score);
}
else
{
@@ -382,13 +341,13 @@
theCurrentResolver,
&resolver);
- doGetMatchScore(context, executionContext, score);
+ doGetMatchScore(node, executionContext, score);
}
}
else
{
executionContext.error(TranscodeFromLocalCodePage("Expected
match pattern in getMatchScore!"),
- context);
+ node);
}
return score;
@@ -527,7 +486,7 @@
score = executeMore(context, opPos, executionContext);
assert(score.null() == false);
- if(score->num() != s_MatchScoreNone)
+ if(score->num() != eMatchScoreNone)
{
break;
}
@@ -537,12 +496,14 @@
}
}
- if(score.null() == true)
+ if(score.null() == false)
{
- score =
executionContext.getXObjectFactory().createNumber(s_MatchScoreNone);
+ return score;
}
-
- return score;
+ else
+ {
+ return
executionContext.getXObjectFactory().createNumber(getMatchScoreValue(eMatchScoreNone));
+ }
}
@@ -901,29 +862,6 @@
const XObjectPtr
-XPath::number(
- XalanNode* context,
- int opPos,
- XPathExecutionContext& executionContext) const
-{
- const XObjectPtr expr1(executeMore(context, opPos + 2,
executionContext));
- assert(expr1.get() != 0);
-
- // Try to optimize when the result of the execution is
- // already a number.
- if (expr1->getType() == XObject::eTypeNumber)
- {
- return expr1;
- }
- else
- {
- return
executionContext.getXObjectFactory().createNumber(expr1->num());
- }
-}
-
-
-
-const XObjectPtr
XPath::Union(
XalanNode* context,
int opPos,
@@ -1050,9 +988,7 @@
{
assert(context != 0);
- XLocator* const locator = m_defaultXLocator;
-
- return locator->locationPath(*this, executionContext, *context, opPos);
+ return SimpleNodeLocator::locationPath(*this, executionContext,
*context, opPos);
}
@@ -1075,12 +1011,11 @@
XPathExecutionContext& executionContext) const
{
assert(context != 0);
-
- XLocator* const locator = m_defaultXLocator;
- const double result = locator->locationPathPattern(*this,
executionContext, *context, opPos);
+ const eMatchScore result =
+ SimpleNodeLocator::locationPathPattern(*this, executionContext,
*context, opPos);
- return executionContext.getXObjectFactory().createNumber(result);
+ return
executionContext.getXObjectFactory().createNumber(getMatchScoreValue(result));
}
@@ -1277,14 +1212,6 @@
const XalanDOMString& XPath::PSEUDONAME_PI = ::PSEUDONAME_PI;
const XalanDOMString& XPath::PSEUDONAME_OTHER = ::PSEUDONAME_OTHER;
const XalanDOMString& XPath::PSEUDONAME_NODE = ::PSEUDONAME_NODE;
-
-
-
-const double XPath::s_MatchScoreNone = -9999999999999.0;
-const double XPath::s_MatchScoreQName = 0.0;
-const double XPath::s_MatchScoreNSWild = -0.25;
-const double XPath::s_MatchScoreNodeTest = -0.5;
-const double XPath::s_MatchScoreOther = 0.5;
1.15 +35 -49 xml-xalan/c/src/XPath/SimpleNodeLocator.hpp
Index: SimpleNodeLocator.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/SimpleNodeLocator.hpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SimpleNodeLocator.hpp 2001/05/03 22:14:03 1.14
+++ SimpleNodeLocator.hpp 2001/07/08 18:40:08 1.15
@@ -69,12 +69,9 @@
-// Base class header file
-#include <XPath/XLocator.hpp>
-
-
-
#include <XPath/MutableNodeRefList.hpp>
+#include <XPath/XObject.hpp>
+#include <XPath/XPath.hpp>
@@ -83,37 +80,21 @@
/**
- * SimpleNodeLocator implements a search of one or more DOM trees. By using
- * the connect function as an extension, the user may specify a directory and
- * a filter specification for XML files that will be searched. This is a
- * singleton class.
+ * SimpleNodeLocator implements a search of one or more DOM trees. It
+ * has no constructors, since it is never instantiated.
*/
-class XALAN_XPATH_EXPORT SimpleNodeLocator : public XLocator
+class XALAN_XPATH_EXPORT SimpleNodeLocator
{
public:
-
- static SimpleNodeLocator*
- getDefaultInstance();
-
- /*
- * Create a SimpleNodeLocator object.
- */
- explicit
- SimpleNodeLocator();
- virtual
- ~SimpleNodeLocator();
-
- // These methods are inherited from XLocator ...
-
- virtual const XObjectPtr
+ static const XObjectPtr
locationPath(
const XPath& xpath,
XPathExecutionContext& executionContext,
XalanNode& context,
int opPos);
- virtual double
+ static XPath::eMatchScore
locationPathPattern(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -122,7 +103,7 @@
protected:
- void
+ static void
step(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -136,18 +117,19 @@
* @param xpath The xpath that is executing
* @param context The current source tree context node
* @param opPos The current position in the xpath operation map array
- * @param scoreHolder a reference to a double to receive the result.
+ * @param scoreHolder a reference to an XPath::eMatchScore to receive
+ * the result.
* @return the last matched context node
*/
- XalanNode*
+ static XalanNode*
stepPattern(
const XPath& xpath,
XPathExecutionContext& executionContext,
XalanNode* context,
int opPos,
- double& scoreHolder);
+ XPath::eMatchScore& scoreHolder);
- int
+ static int
findNodeSet(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -156,7 +138,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findRoot(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -165,7 +147,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findParent(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -174,7 +156,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findSelf(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -183,7 +165,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findAncestors(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -192,7 +174,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findAncestorsOrSelf(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -201,7 +183,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findAttributes(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -210,7 +192,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findChildren(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -219,7 +201,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findDescendants(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -228,7 +210,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findFollowing(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -237,7 +219,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findFollowingSiblings(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -246,7 +228,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findPreceeding(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -255,7 +237,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findPreceedingSiblings(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -264,7 +246,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findNamespace(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -273,7 +255,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- int
+ static int
findNodesOnUnknownAxis(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -282,7 +264,7 @@
int stepType,
MutableNodeRefList& subQueryResults);
- double
+ static XPath::eMatchScore
nodeTest(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -292,7 +274,7 @@
int argLen,
int stepType);
- void
+ static void
predicates(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -301,7 +283,7 @@
MutableNodeRefList& subQueryResults,
int&
endPredicatesPos);
- double
+ static XPath::eMatchScore
handleFoundIndex(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -309,8 +291,12 @@
int startOpPos);
private:
+
+ // Not defined...
+ SimpleNodeLocator();
+
+ ~SimpleNodeLocator();
- static SimpleNodeLocator s_defaultInstance;
static const XalanDOMString s_emptyString;
};
1.40 +88 -125 xml-xalan/c/src/XPath/SimpleNodeLocator.cpp
Index: SimpleNodeLocator.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/SimpleNodeLocator.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- SimpleNodeLocator.cpp 2001/06/06 21:47:54 1.39
+++ SimpleNodeLocator.cpp 2001/07/08 18:40:08 1.40
@@ -79,33 +79,10 @@
-SimpleNodeLocator SimpleNodeLocator::s_defaultInstance;
-
const XalanDOMString SimpleNodeLocator::s_emptyString;
-SimpleNodeLocator*
-SimpleNodeLocator::getDefaultInstance()
-{
- return &s_defaultInstance;
-}
-
-
-
-SimpleNodeLocator::SimpleNodeLocator() :
- XLocator()
-{
-}
-
-
-
-SimpleNodeLocator::~SimpleNodeLocator()
-{
-}
-
-
-
const XObjectPtr
SimpleNodeLocator::locationPath(
const XPath& xpath,
@@ -124,14 +101,14 @@
-double
+XPath::eMatchScore
SimpleNodeLocator::locationPathPattern(
const XPath& xpath,
XPathExecutionContext& executionContext,
XalanNode& context,
int opPos)
{
- double score = xpath.s_MatchScoreNone;
+ XPath::eMatchScore score = XPath::eMatchScoreNone;
stepPattern(xpath, executionContext, &context, opPos + 2, score);
@@ -316,7 +293,7 @@
XPathExecutionContext& executionContext,
XalanNode* context,
int opPos,
- double& scoreHolder)
+ XPath::eMatchScore& scoreHolder)
{
const XPathExpression& currentExpression =
xpath.getExpression();
@@ -336,17 +313,17 @@
if(0 == context)
{
- scoreHolder = xpath.s_MatchScoreNone;
+ scoreHolder = XPath::eMatchScoreNone;
}
- if (scoreHolder == xpath.s_MatchScoreNone)
+ if (scoreHolder == XPath::eMatchScoreNone)
{
// !!!!!!!!!!!!! Big ugly return here
!!!!!!!!!!!!!!!!!!!
return 0;
}
- scoreHolder = xpath.s_MatchScoreOther;
+ scoreHolder = XPath::eMatchScoreOther;
if (nextStepType !=
XPathExpression::eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL)
{
@@ -362,9 +339,9 @@
assert(context != 0);
- int argLen = 0;
+ int argLen = 0;
- double score = xpath.s_MatchScoreNone;
+ XPath::eMatchScore score = XPath::eMatchScoreNone;
const int startOpPos = opPos;
const int stepType = currentExpression.getOpCodeMapValue(opPos);
@@ -377,7 +354,7 @@
case XPathExpression::eOP_FUNCTION:
{
- argLen = currentExpression.getOpCodeLength(opPos);
+ argLen =
currentExpression.getOpCodeLengthFromOpMap(opPos);
const XObjectPtr
obj(xpath.executeMore(context, opPos, executionContext));
assert(obj.get() != 0);
@@ -386,8 +363,6 @@
const unsigned int len = nl.getLength();
- score = xpath.s_MatchScoreNone;
-
if (nextStepType ==
XPathExpression::eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL)
{
bool fFound = false;
@@ -400,7 +375,7 @@
if(n == context)
{
- score =
xpath.s_MatchScoreOther;
+ score =
XPath::eMatchScoreOther;
context = n;
@@ -421,7 +396,7 @@
if(n == context)
{
- score = xpath.s_MatchScoreOther;
+ score = XPath::eMatchScoreOther;
context = n;
@@ -437,7 +412,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -446,14 +421,14 @@
if (nodeType == XalanNode::DOCUMENT_NODE ||
nodeType == XalanNode::DOCUMENT_FRAGMENT_NODE)
{
- score = XPath::s_MatchScoreOther;
+ score = XPath::eMatchScoreOther;
}
else
{
const int prevPos =
currentExpression.getNextOpCodePosition(startOpPos);
const int prevStepType =
currentExpression.getOpCodeMapValue(prevPos);
- if (xpath.s_MatchScoreNone == score &&
+ if (XPath::eMatchScoreNone == score &&
(prevStepType ==
XPathExpression::eMATCH_ANY_ANCESTOR ||
prevStepType ==
XPathExpression::eMATCH_ANY_ANCESTOR_WITH_PREDICATE))
{
@@ -468,7 +443,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone !=
score)
+ if(XPath::eMatchScoreNone !=
score)
break;
context =
DOMServices::getParentOfNode(*context);
@@ -483,7 +458,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -503,7 +478,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
-
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
XalanNode::NodeType nodeType =
context->getNodeType();
@@ -515,7 +490,7 @@
{
score = nodeTest(xpath,
executionContext, context, nodeType, opPos, argLen, stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
break;
context =
DOMServices::getParentOfNode(*context);
@@ -534,7 +509,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
const XalanNode::NodeType nodeType =
context->getNodeType();
@@ -556,9 +531,9 @@
nextStepType = currentExpression.getOpCodeMapValue(opPos);
- if(score != xpath.s_MatchScoreNone && XPathExpression::eOP_PREDICATE ==
nextStepType)
+ if(score != XPath::eMatchScoreNone && XPathExpression::eOP_PREDICATE ==
nextStepType)
{
- score = xpath.s_MatchScoreOther;
+ score = XPath::eMatchScoreOther;
// Execute the xpath.predicates, but if we have an index, then
we have
// to start over and do a search from the parent. It would be
nice
@@ -578,9 +553,9 @@
}
else if(pred->boolean() == false)
{
- score = xpath.s_MatchScoreNone;
+ score = XPath::eMatchScoreNone;
- break; // from while(xpath.OP_PREDICATE
== nextStepType)
+ break;
}
opPos =
currentExpression.getNextOpCodePosition(opPos);
@@ -595,18 +570,18 @@
}
}
- if (scoreHolder == xpath.s_MatchScoreNone ||
- score == xpath.s_MatchScoreNone)
+ if (scoreHolder == XPath::eMatchScoreNone ||
+ score == XPath::eMatchScoreNone)
{
scoreHolder = score;
}
- return score == xpath.s_MatchScoreNone ? 0 : context;
+ return score == XPath::eMatchScoreNone ? 0 : context;
}
-double
+XPath::eMatchScore
SimpleNodeLocator::handleFoundIndex(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -625,7 +600,7 @@
if (parentContext == 0)
{
- return XPath::s_MatchScoreNone;
+ return XPath::eMatchScoreNone;
}
else
{
@@ -637,11 +612,11 @@
if (mnl->indexOf(localContext) == MutableNodeRefList::npos)
{
- return XPath::s_MatchScoreNone;
+ return XPath::eMatchScoreNone;
}
else
{
- return XPath::s_MatchScoreOther;
+ return XPath::eMatchScoreOther;
}
}
}
@@ -668,7 +643,7 @@
// $$$ ToDo: Should this be adding in doc order?
subQueryResults.addNodes(nl);
- return currentExpression.getOpCodeLength(opPos);
+ return currentExpression.getOpCodeLengthFromOpMap(opPos);
}
@@ -688,7 +663,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
XalanNode* const docContext = XalanNode::DOCUMENT_NODE ==
context->getNodeType() ?
context
:
@@ -717,7 +692,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -727,7 +702,7 @@
{
if(argLen > 0)
{
- const double score = nodeTest(xpath,
+ const XPath::eMatchScore score = nodeTest(xpath,
executionContext,
theParent,
theParent->getNodeType(),
@@ -735,7 +710,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNode(theParent);
}
@@ -766,13 +741,13 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
if(argLen > 0)
{
- const double score = nodeTest(xpath,
+ const XPath::eMatchScore score = nodeTest(xpath,
executionContext,
context,
context->getNodeType(),
@@ -780,7 +755,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNode(context);
}
@@ -813,13 +788,13 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
while(0 != contextNode)
{
- const double score = nodeTest(xpath,
+ const XPath::eMatchScore score = nodeTest(xpath,
executionContext,
contextNode,
contextNode->getNodeType(),
@@ -827,7 +802,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNode(contextNode);
}
@@ -860,13 +835,13 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
while(0 != contextNode)
{
- const double score = nodeTest(xpath,
+ const XPath::eMatchScore score = nodeTest(xpath,
executionContext,
contextNode,
contextNode->getNodeType(),
@@ -874,7 +849,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNode(contextNode);
}
@@ -902,7 +877,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
if(0 != context && context->getNodeType() == XalanNode::ELEMENT_NODE)
{
@@ -926,7 +901,7 @@
XalanNode* const theNode =
attributeList->item(j);
assert(theNode != 0 && theNode->getNodeType()
== XalanNode::ATTRIBUTE_NODE);
- const double score = nodeTest(xpath,
+ const XPath::eMatchScore score =
nodeTest(xpath,
executionContext,
theNode,
XalanNode::ATTRIBUTE_NODE,
@@ -934,7 +909,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNode(theNode);
}
@@ -962,7 +937,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -970,7 +945,7 @@
while(0 != child)
{
- const double score = nodeTest(xpath,
+ const XPath::eMatchScore score = nodeTest(xpath,
executionContext,
child,
child->getNodeType(),
@@ -978,7 +953,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNode(child);
}
@@ -1006,22 +981,11 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
- // Perform a pre-order traversal of descendents.
- // Note that I would like to be able to do optimization here
- // where if I have a simple tag name node test, I would
- // like to be able to call
- // ((Element)context).getElementsByTagName(m_token).
- // One problem is that it would return a NodeList, not a
- // NodeListImpl.
- /*
- if(lookahead('[', 1) || lookahead('(', 1)
- || (Node.ELEMENT_NODE != context.getNodeType()))
- {
- */
+ // Perform a pre-order traversal of descendents...
XalanNode* pos = context;
while(0 != pos)
@@ -1029,15 +993,14 @@
if(stepType == XPathExpression::eFROM_DESCENDANTS_OR_SELF ||
context != pos)
{
- const double score = nodeTest(xpath,
-
executionContext,
-
pos,
-
pos->getNodeType(),
-
opPos,
-
argLen,
-
stepType);
-
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != nodeTest(
+ xpath,
+ executionContext,
+ pos,
+ pos->getNodeType(),
+ opPos,
+ argLen,
+ stepType))
{
subQueryResults.addNode(pos);
}
@@ -1087,7 +1050,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -1102,7 +1065,7 @@
if(pos != context)
{
- const double score = nodeTest(xpath,
+ const XPath::eMatchScore score = nodeTest(xpath,
executionContext,
pos,
pos->getNodeType(),
@@ -1110,7 +1073,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNodeInDocOrder(pos,
executionContext);
}
@@ -1178,7 +1141,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -1186,7 +1149,7 @@
while(0 != pos)
{
- const double score = nodeTest(xpath,
+ const XPath::eMatchScore score = nodeTest(xpath,
executionContext,
pos,
pos->getNodeType(),
@@ -1194,7 +1157,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNode(pos);
}
@@ -1222,7 +1185,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -1255,7 +1218,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
// Ugh. If I could think a little better tonight, I'm
// sure there's a better way to check for the parent.
@@ -1332,7 +1295,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -1348,7 +1311,7 @@
argLen,
stepType);
- if(xpath.s_MatchScoreNone != score)
+ if(XPath::eMatchScoreNone != score)
{
subQueryResults.addNode(pos);
}
@@ -1376,7 +1339,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
opPos += 3;
@@ -1416,7 +1379,7 @@
XalanNode::ATTRIBUTE_NODE,
opPos,
argLen,
-
stepType) != xpath.s_MatchScoreNone)
+
stepType) != XPath::eMatchScoreNone)
{
subQueryResults.addNode(attr);
}
@@ -1448,7 +1411,7 @@
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
- currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
+ currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
executionContext.error(TranscodeFromLocalCodePage("Unknown axis!"),
context);
@@ -1457,7 +1420,7 @@
-double
+XPath::eMatchScore
SimpleNodeLocator::nodeTest(
const XPath& xpath,
XPathExecutionContext& executionContext,
@@ -1472,7 +1435,7 @@
const XPathExpression& currentExpression =
xpath.getExpression();
- double score = xpath.s_MatchScoreNone;
+ XPath::eMatchScore score = XPath::eMatchScoreNone;
const int testType = currentExpression.getOpCodeMapValue(opPos);
@@ -1481,7 +1444,7 @@
case XPathExpression::eNODETYPE_COMMENT:
if (XalanNode::COMMENT_NODE == nodeType)
{
- score = xpath.s_MatchScoreNodeTest;
+ score = XPath::eMatchScoreNodeTest;
}
break;
@@ -1490,7 +1453,7 @@
XalanNode::TEXT_NODE == nodeType) &&
executionContext.shouldStripSourceNode(*context) ==
false)
{
- score = xpath.s_MatchScoreNodeTest;
+ score = XPath::eMatchScoreNodeTest;
}
break;
@@ -1501,7 +1464,7 @@
if(argLen == 1)
{
- score = xpath.s_MatchScoreNodeTest;
+ score = XPath::eMatchScoreNodeTest;
}
else if(argLen == 2)
{
@@ -1514,7 +1477,7 @@
if (equals(context->getNodeName(), name->str())
== true)
{
- score = xpath.s_MatchScoreQName;
+ score = XPath::eMatchScoreQName;
}
}
else
@@ -1531,12 +1494,12 @@
{
if (executionContext.shouldStripSourceNode(*context) ==
false)
{
- score = xpath.s_MatchScoreNodeTest;
+ score = XPath::eMatchScoreNodeTest;
}
}
else
{
- score = xpath.s_MatchScoreNodeTest;
+ score = XPath::eMatchScoreNodeTest;
}
break;
@@ -1544,7 +1507,7 @@
if (XalanNode::DOCUMENT_FRAGMENT_NODE == nodeType ||
XalanNode::DOCUMENT_NODE == nodeType)
{
- score = xpath.s_MatchScoreOther;
+ score = XPath::eMatchScoreOther;
}
break;
@@ -1628,14 +1591,14 @@
{
if
(isNamespace == false)
{
-
score = xpath.s_MatchScoreNodeTest;
+
score = XPath::eMatchScoreNodeTest;
}
}
else
{
if
(isNamespace == true)
{
-
score = xpath.s_MatchScoreNodeTest;
+
score = XPath::eMatchScoreNodeTest;
}
}
}
@@ -1655,7 +1618,7 @@
if (equals(localAttrName, targetLocalName) == true)
{
-
score = xpath.s_MatchScoreQName;
+
score = XPath::eMatchScoreQName;
}
}
}
@@ -1681,7 +1644,7 @@
if (equals(theNamespace, targetLocalName) == true)
{
-
score = xpath.s_MatchScoreQName;
+
score = XPath::eMatchScoreQName;
}
}
}
@@ -1695,7 +1658,7 @@
if(XPathExpression::eELEMWILDCARD == queueIndex)
{
score =
didMatchNS == true ?
-
XPath::s_MatchScoreNSWild : XPath::s_MatchScoreNodeTest;
+
XPath::eMatchScoreNSWild : XPath::eMatchScoreNodeTest;
}
else
{
@@ -1707,7 +1670,7 @@
if
(equals(DOMServices::getLocalNameOfNode(*context),
targetLocalName) == true)
{
- score =
xpath.s_MatchScoreQName;
+ score =
XPath::eMatchScoreQName;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]