]> git.tokkee.org Git - inkscape.git/commitdiff

Code

Rework Stack class to TokenExecutor, to support an Axis stack
authorishmal <ishmal@users.sourceforge.net>
Sun, 30 Apr 2006 00:34:33 +0000 (00:34 +0000)
committerishmal <ishmal@users.sourceforge.net>
Sun, 30 Apr 2006 00:34:33 +0000 (00:34 +0000)
src/dom/dom.h
src/dom/xpathparser.cpp
src/dom/xpathtoken.cpp
src/dom/xpathtoken.h

index ab82c429819a95d7f555d3c1ce50e940df9b4426..6741d375dbc5916bc62700348d476f557b828f6b 100644 (file)
@@ -882,6 +882,14 @@ public:
      */
     virtual ~NodeList() {}
 
+    /**
+     *
+     */
+    virtual void clear()
+        {
+        nodes.clear();
+        }
+
 protected:
 
 friend class NodeImpl;
index 47a9a146af80c3f7fe875ef2c2d05d7f77d3f20b..cc6488eed5276b514c6ea9aaf06e88933396c9c9 100644 (file)
@@ -730,6 +730,8 @@ int XPathParser::getRelativeLocationPath(int p0, int depth)
         if (t.getType() == OPERATOR && t.getIntValue()==DOUBLE_SLASH)\r
             {\r
             p++;\r
+            // a '//' is an abbreviation for /descendant-or-self:node()/\r
+            tokAdd(new TokAxisDescendantOrSelf());\r
             p2 = getRelativeLocationPath(p, depth+1);\r
             if (p2 < 0)\r
                 {\r
@@ -2024,7 +2026,8 @@ NodeList XPathParser::evaluate(const Node *root,
         tokens.dump();\r
 \r
     //### Execute the token list\r
-    list = tokens.execute(root);\r
+    TokenExecutor executor;\r
+    list = executor.execute(tokens, root);\r
 \r
     return list;\r
 }\r
index 5de011959ee8d5403b7d1c03904ca59cdce3e81a..c9d4898d78a723e9705b52e483b2077ef17ba59f 100644 (file)
@@ -131,12 +131,12 @@ static TokenStringPair tokenStrings[] =
 \r
 \r
 /**\r
- *  Return the enumerated TokenType of this token\r
+ *  Return the string TokenType of this token\r
  *  (in the .cpp file)\r
  */\r
 DOMString Token::getTypeString()\r
 {\r
-    DOMString ret;\r
+    DOMString ret = "unknown";\r
     for (TokenStringPair *pair = tokenStrings ; pair->sval ; pair++)\r
         {\r
         if (pair->ival == type)\r
@@ -148,25 +148,37 @@ DOMString Token::getTypeString()
     return ret;\r
 }\r
 \r
+\r
+\r
 //########################################################################\r
-//# X P A T H    S T A C K    I T E M\r
+//# X P A T H    A X I S\r
 //########################################################################\r
 \r
 /**\r
  *\r
  */\r
-StackItem::StackItem()\r
+Axis::Axis()\r
 {\r
-    ival = 0L;\r
-    dval = 0.0;\r
+    init();\r
 }\r
 \r
 \r
 /**\r
  *\r
  */\r
-StackItem::StackItem(const StackItem &other)\r
+Axis::Axis(int tokPos)\r
+{\r
+    init();\r
+    tokenPosition = tokPos;\r
+}\r
+\r
+\r
+/**\r
+ *\r
+ */\r
+Axis::Axis(const Axis &other)\r
 {\r
+    init();\r
     assign(other);\r
 }\r
 \r
@@ -174,7 +186,7 @@ StackItem::StackItem(const StackItem &other)
 /**\r
  *\r
  */\r
-StackItem::~StackItem()\r
+Axis::~Axis()\r
 {\r
 }\r
 \r
@@ -182,7 +194,7 @@ StackItem::~StackItem()
 /**\r
  *\r
  */\r
-StackItem &StackItem::operator=(const StackItem &other)\r
+Axis &Axis::operator=(const Axis &other)\r
 {\r
     assign(other);\r
     return *this;\r
@@ -191,111 +203,99 @@ StackItem &StackItem::operator=(const StackItem &other)
 /**\r
  *\r
  */\r
-void StackItem::assign(const StackItem &other)\r
+void Axis::init()\r
 {\r
-    sval = other.sval;\r
-    ival = other.ival;\r
-    dval = other.dval;\r
+    tokenPosition = 0;\r
 }\r
 \r
-\r
-//########################################################################\r
-//# X P A T H    S T A C K\r
-//########################################################################\r
-\r
 /**\r
  *\r
  */\r
-Stack::Stack()\r
+void Axis::assign(const Axis &other)\r
 {\r
-    size = 0;\r
+    tokenPosition = other.tokenPosition;\r
 }\r
 \r
-\r
 /**\r
  *\r
  */\r
-Stack::Stack(const Stack &other)\r
+void Axis::setPosition(unsigned int val)\r
 {\r
-    assign(other);\r
+    tokenPosition = val;\r
 }\r
 \r
-\r
 /**\r
  *\r
  */\r
-Stack::~Stack()\r
+unsigned int Axis::getPosition()\r
 {\r
+    return tokenPosition;\r
 }\r
 \r
-\r
 /**\r
  *\r
  */\r
-void Stack::assign(const Stack &other)\r
+void Axis::setNode(const Node *val)\r
 {\r
-    root = other.root;\r
-    nodeList = other.nodeList;\r
-    size = other.size;\r
-    for (int i=0 ; i<size ; i++)\r
-        items[i] = other.items[i];\r
+    node = (Node *)val;\r
 }\r
 \r
-\r
 /**\r
  *\r
  */\r
-void Stack::reset()\r
+Node *Axis::getNode()\r
 {\r
-    root = NULL;\r
-    NodeList n; /*no "clear" in api*/\r
-    nodeList = n;\r
-    size = 0;\r
+    return node;\r
 }\r
 \r
+//########################################################################\r
+//# X P A T H    S T A C K    I T E M\r
+//########################################################################\r
 \r
+/**\r
+ *\r
+ */\r
+StackItem::StackItem()\r
+{\r
+    ival = 0L;\r
+    dval = 0.0;\r
+}\r
 \r
 \r
 /**\r
  *\r
  */\r
-void Stack::push(StackItem &item)\r
+StackItem::StackItem(const StackItem &other)\r
 {\r
-    if (size>=STACK_SIZE)\r
-        {\r
-        return;\r
-        }\r
-    items[size++] = item;\r
+    assign(other);\r
 }\r
 \r
+\r
 /**\r
  *\r
  */\r
-StackItem Stack::pop()\r
+StackItem::~StackItem()\r
 {\r
-    if (size<1)\r
-        {\r
-        StackItem item;\r
-        return item;\r
-        }\r
-    return items[--size];\r
 }\r
 \r
+\r
 /**\r
- * Set the root node\r
+ *\r
  */\r
-void Stack::setRootNode(const Node *node)\r
+StackItem &StackItem::operator=(const StackItem &other)\r
 {\r
-    root = (Node *)node;\r
+    assign(other);\r
+    return *this;\r
 }\r
 \r
-\r
 /**\r
- * Get the current node list;\r
+ *\r
  */\r
-NodeList &Stack::getNodeList()\r
+void StackItem::assign(const StackItem &other)\r
 {\r
-    return nodeList;\r
+    sval = other.sval;\r
+    ival = other.ival;\r
+    dval = other.dval;\r
 }\r
 \r
 \r
@@ -365,48 +365,140 @@ void TokenList::add(Token *tok)
     tokens.push_back(tok);\r
 }\r
 \r
+\r
 /**\r
- *  This method "executes" a list of Tokens in the context of a DOM root\r
- *  Node, returning a list of Nodes that match the xpath expression.\r
+ *\r
  */\r
-NodeList TokenList::execute(const Node *root)\r
+unsigned int TokenList::size() const\r
 {\r
-    NodeList list;\r
-\r
-    if (!root)\r
-        return list;\r
+    return (unsigned int)tokens.size();\r
+}\r
 \r
-    Stack stack;\r
-    stack.setRootNode(root);\r
 \r
-    //### Execute the token list\r
+/**\r
+ *\r
+ */\r
+void TokenList::dump()\r
+{\r
     std::vector<Token *>::iterator iter;\r
+    printf("############# TOKENS\n");\r
     for (iter = tokens.begin() ; iter != tokens.end() ; iter++)\r
         {\r
         Token *tok = *iter;\r
-        tok->execute(stack);\r
+        tok->dump();\r
         }\r
+}\r
 \r
-    list = stack.getNodeList();\r
 \r
-    return list;\r
+//########################################################################\r
+//# X P A T H    E X E C U T O R\r
+//########################################################################\r
+\r
+/**\r
+ *\r
+ */\r
+TokenExecutor::TokenExecutor()\r
+{\r
+    reset();\r
 }\r
 \r
 \r
 /**\r
  *\r
  */\r
-void TokenList::dump()\r
+TokenExecutor::TokenExecutor(const TokenExecutor &other)\r
 {\r
-    std::vector<Token *>::iterator iter;\r
-    printf("############# TOKENS\n");\r
-    for (iter = tokens.begin() ; iter != tokens.end() ; iter++)\r
+    reset();\r
+    assign(other);\r
+}\r
+\r
+\r
+/**\r
+ *\r
+ */\r
+TokenExecutor::~TokenExecutor()\r
+{\r
+}\r
+\r
+\r
+/**\r
+ *\r
+ */\r
+void TokenExecutor::assign(const TokenExecutor &other)\r
+{\r
+    axis        = other.axis;\r
+    axisStack   = other.axisStack;\r
+    stackSize   = other.stackSize;\r
+    for (int i=0 ; i<stackSize ; i++)\r
+        stack[i] = other.stack[i];\r
+}\r
+\r
+\r
+/**\r
+ *\r
+ */\r
+void TokenExecutor::reset()\r
+{\r
+    axis.setPosition(0);\r
+    axis.setNode(NULL);\r
+    stackSize = 0;\r
+}\r
+\r
+\r
+\r
+\r
+/**\r
+ * Set the root node\r
+ */\r
+NodeList TokenExecutor::execute(const TokenList &tokens, const Node *node)\r
+{\r
+\r
+    axis.setPosition(0);\r
+    axis.setNode(node);\r
+\r
+    nodeList.clear();\r
+\r
+    while (axis.getPosition() < tokens.size())\r
         {\r
-        Token *tok = *iter;\r
-        tok->dump();\r
         }\r
+\r
+    return nodeList;\r
+}\r
+\r
+\r
+\r
+\r
+\r
+/**\r
+ *\r
+ */\r
+void TokenExecutor::push(StackItem &item)\r
+{\r
+    if (stackSize>=STACK_SIZE)\r
+        {\r
+        return;\r
+        }\r
+    stack[stackSize++] = item;\r
 }\r
 \r
+/**\r
+ *\r
+ */\r
+StackItem TokenExecutor::pop()\r
+{\r
+    if (stackSize<1)\r
+        {\r
+        StackItem item;\r
+        return item;\r
+        }\r
+    return stack[--stackSize];\r
+}\r
+\r
+\r
+\r
+\r
+\r
+\r
 \r
 \r
 \r
index 8961f80aa92809ce7620cb6dc4aec0c2ba4bb2e8..d595ad43c7aac9a3d4833607a954778064e91c14 100644 (file)
@@ -48,6 +48,72 @@ namespace xpath
 \r
 typedef org::w3c::dom::DOMString DOMString;\r
 \r
+class Axis\r
+{\r
+public:\r
+    /**\r
+     *  Constructor\r
+     */\r
+    Axis();\r
+\r
+    /**\r
+     *  Constructor\r
+     */\r
+    Axis(int tokPos);\r
+\r
+    /**\r
+     *  Copy constructor\r
+     */\r
+    Axis(const Axis &other);\r
+\r
+    /**\r
+     *  Destructor\r
+     */\r
+    virtual ~Axis();\r
+\r
+    /**\r
+     *\r
+     */\r
+    Axis &operator=(const Axis &other);\r
+\r
+    /**\r
+     *\r
+     */\r
+    void init();\r
+\r
+    /**\r
+     *\r
+     */\r
+    void assign(const Axis &other);\r
+\r
+    /**\r
+     *\r
+     */\r
+    void setPosition(unsigned int val);\r
+\r
+    /**\r
+     *\r
+     */\r
+    unsigned int getPosition();\r
+\r
+    /**\r
+     *\r
+     */\r
+    void setNode(const Node *node);\r
+\r
+    /**\r
+     *\r
+     */\r
+    Node *getNode();\r
+\r
+private:\r
+\r
+    int tokenPosition;\r
+\r
+    Node *node;\r
+};\r
+\r
+\r
 /**\r
  * This represents a single value on the evaluation stack\r
  */\r
@@ -100,34 +166,40 @@ public:
 \r
 };\r
 \r
+class TokenList;\r
+\r
+//########################################################################\r
+//# T O K E N    E X E C U T O R\r
+//########################################################################\r
+\r
 #define STACK_SIZE 1024\r
 \r
 /**\r
- * An evaluation stack\r
+ * A token evaluator, with stack and axis context\r
  */\r
-class Stack\r
+class TokenExecutor\r
 {\r
 public:\r
 \r
     /**\r
      * Constructor\r
      */\r
-    Stack();\r
+    TokenExecutor();\r
 \r
     /**\r
      * Copy constructor\r
      */\r
-    Stack(const Stack &other);\r
+    TokenExecutor(const TokenExecutor &other);\r
 \r
     /**\r
      * Destructor\r
      */\r
-    virtual ~Stack();\r
+    virtual ~TokenExecutor();\r
 \r
     /**\r
      *  Assign our values to those of the other\r
      */\r
-    virtual void assign(const Stack &other);\r
+    virtual void assign(const TokenExecutor &other);\r
 \r
     /**\r
      * Reset the stack to its original settings\r
@@ -145,27 +217,47 @@ public:
     virtual StackItem pop();\r
 \r
     /**\r
-     * Set the root node\r
+     * Execute a token list on the stack\r
      */\r
-    virtual void setRootNode(const Node *node);\r
+    NodeList execute(const TokenList &list, const Node *node);\r
 \r
     /**\r
-     * Get the current node list;\r
+     *\r
      */\r
-    virtual NodeList &getNodeList();\r
+    Axis axis;\r
 \r
+    /**\r
+     *\r
+     */\r
+    std::vector<Axis> axisStack;\r
 \r
 private:\r
 \r
-    Node *root;\r
+    /**\r
+     * Contains the StackItem stack;\r
+     */\r
+    StackItem stack[STACK_SIZE];\r
+\r
+    /**\r
+     * Marks the head of the stack, for push() and pop()\r
+     */\r
+    int stackSize;\r
+\r
+    /**\r
+     *  Current list of nodes found by the expression\r
+     */\r
     NodeList nodeList;\r
 \r
-    StackItem items[STACK_SIZE];\r
-    int size;\r
+\r
 };\r
 \r
 \r
 \r
+//########################################################################\r
+//# X P A T H    T O K E N\r
+//########################################################################\r
+\r
+\r
 \r
 /**\r
  *  This is a pseudocode-type class that executes itself on a stack,\r
@@ -295,8 +387,7 @@ public:
     virtual int getType()\r
         { return type; }\r
     /**\r
-     *  Return the enumerated TokenType of this token\r
-     *  (in the .cpp file)\r
+     *  Return the string TokenType of this token\r
      */\r
     virtual DOMString getTypeString();\r
 \r
@@ -304,7 +395,7 @@ public:
      *  Let this token execute itself on the given stack,\r
      *  possibly adding Nodes to the node list.\r
      */\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &stack)\r
         { return true; }\r
 \r
     /**\r
@@ -348,7 +439,7 @@ private:
 \r
 \r
 //########################################################################\r
-//# X P A T H    T O K E N\r
+//# X P A T H    T O K E N    T Y P E S\r
 //########################################################################\r
 \r
 \r
@@ -365,11 +456,11 @@ public:
         type = TOK_STR;\r
         sval = val;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         StackItem item;\r
         item.sval = sval;\r
-        stack.push(item);\r
+        exec.push(item);\r
         return true;\r
         }\r
 };\r
@@ -382,11 +473,11 @@ public:
         type = TOK_FLOAT;\r
         dval = val;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         StackItem item;\r
         item.dval = dval;\r
-        stack.push(item);\r
+        exec.push(item);\r
         return true;\r
         }\r
 };\r
@@ -399,11 +490,11 @@ public:
         type = TOK_INT;\r
         ival = val;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         StackItem item;\r
         item.ival = ival;\r
-        stack.push(item);\r
+        exec.push(item);\r
         return true;\r
         }\r
 };\r
@@ -415,12 +506,12 @@ public:
         {\r
         type = TOK_AND;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.ival = item1.ival && item2.ival;\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -432,12 +523,12 @@ public:
         {\r
         type = TOK_OR;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.ival = item1.ival || item2.ival;\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -449,12 +540,12 @@ public:
         {\r
         type = TOK_MOD;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.dval = fmod(item1.dval, item2.dval);\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -466,12 +557,12 @@ public:
         {\r
         type = TOK_DIV;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.dval /= item2.dval;\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -483,12 +574,12 @@ public:
         {\r
         type = TOK_MULTIPLY;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.dval *= item2.dval;\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -500,12 +591,12 @@ public:
         {\r
         type = TOK_PLUS;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.dval += item2.dval;\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -517,12 +608,12 @@ public:
         {\r
         type = TOK_MINUS;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.dval -= item2.dval;\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -534,12 +625,12 @@ public:
         {\r
         type = TOK_NEG;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item;\r
-        item.dval = -dval;\r
-        item.ival = -ival;\r
-        stack.push(item);\r
+        StackItem item = exec.pop();\r
+        item.dval = -item.dval;\r
+        item.ival = -item.ival;\r
+        exec.push(item);\r
         return true;\r
         }\r
 };\r
@@ -551,12 +642,12 @@ public:
         {\r
         type = TOK_EQUALS;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.ival = (item1.dval == item2.dval);\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -568,12 +659,12 @@ public:
         {\r
         type = TOK_NOT_EQUALS;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.ival = (item1.dval != item2.dval);\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -585,12 +676,12 @@ public:
         {\r
         type = TOK_LESS_THAN_EQUALS;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.ival = (item1.dval <= item2.dval);\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -602,12 +693,12 @@ public:
         {\r
         type = TOK_LESS_THAN;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.ival = (item1.dval < item2.dval);\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -619,12 +710,12 @@ public:
         {\r
         type = TOK_GREATER_THAN_EQUALS;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.ival = (item1.dval >= item2.dval);\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -636,12 +727,12 @@ public:
         {\r
         type = TOK_GREATER_THAN;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
-        StackItem item1 = stack.pop();\r
-        StackItem item2 = stack.pop();\r
+        StackItem item1 = exec.pop();\r
+        StackItem item2 = exec.pop();\r
         item1.ival = (item1.dval > item2.dval);\r
-        stack.push(item1);\r
+        exec.push(item1);\r
         return true;\r
         }\r
 };\r
@@ -658,8 +749,12 @@ public:
         {\r
         type = TOK_ABSOLUTE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
+        Node *n = exec.axis.getNode();\r
+        while (n->getParentNode())\r
+             n = n->getParentNode();\r
+        exec.axis.setNode(n);\r
         return true;\r
         }\r
 };\r
@@ -671,8 +766,9 @@ public:
         {\r
         type = TOK_RELATIVE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
+        ///exec.axis.currentNode = stack.rootNode;\r
         return true;\r
         }\r
 };\r
@@ -684,7 +780,7 @@ public:
         {\r
         type = TOK_STEP;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -698,7 +794,7 @@ public:
         type  = TOK_NAME_TEST;\r
         sval  = name;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -711,7 +807,7 @@ public:
         {\r
         type = TOK_EXPR;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -724,7 +820,7 @@ public:
         {\r
         type = TOK_UNION;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -745,7 +841,7 @@ public:
         {\r
         type = TOK_AXIS_ANCESTOR_OR_SELF;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -758,7 +854,7 @@ public:
         {\r
         type = TOK_AXIS_ANCESTOR;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -771,7 +867,7 @@ public:
         {\r
         type = TOK_AXIS_ATTRIBUTE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -784,7 +880,7 @@ public:
         {\r
         type = TOK_AXIS_CHILD;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -797,7 +893,7 @@ public:
         {\r
         type = TOK_AXIS_DESCENDANT_OR_SELF;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -810,7 +906,7 @@ public:
         {\r
         type = TOK_AXIS_DESCENDANT;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -823,7 +919,7 @@ public:
         {\r
         type = TOK_AXIS_FOLLOWING_SIBLING;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -836,7 +932,7 @@ public:
         {\r
         type = TOK_AXIS_FOLLOWING;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -849,7 +945,7 @@ public:
         {\r
         type = TOK_AXIS_NAMESPACE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -862,7 +958,7 @@ public:
         {\r
         type = TOK_AXIS_PARENT;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -875,7 +971,7 @@ public:
         {\r
         type = TOK_AXIS_PRECEDING_SIBLING;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -888,7 +984,7 @@ public:
         {\r
         type = TOK_AXIS_PRECEDING;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -901,7 +997,7 @@ public:
         {\r
         type = TOK_AXIS_SELF;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -920,7 +1016,7 @@ public:
         {\r
         type = TOK_FUNC_LAST;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -933,7 +1029,7 @@ public:
         {\r
         type = TOK_FUNC_POSITION;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -946,7 +1042,7 @@ public:
         {\r
         type = TOK_FUNC_COUNT;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -959,7 +1055,7 @@ public:
         {\r
         type = TOK_FUNC_ID;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -972,7 +1068,7 @@ public:
         {\r
         type = TOK_FUNC_LOCAL_NAME;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -985,7 +1081,7 @@ public:
         {\r
         type = TOK_FUNC_NAMESPACE_URI;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -998,7 +1094,7 @@ public:
         {\r
         type = TOK_FUNC_NAME;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1011,7 +1107,7 @@ public:
         {\r
         type = TOK_FUNC_STRING;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1024,7 +1120,7 @@ public:
         {\r
         type = TOK_FUNC_CONCAT;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1037,7 +1133,7 @@ public:
         {\r
         type = TOK_FUNC_STARTS_WITH;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1050,7 +1146,7 @@ public:
         {\r
         type = TOK_FUNC_CONTAINS;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1063,7 +1159,7 @@ public:
         {\r
         type = TOK_FUNC_SUBSTRING_BEFORE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1076,7 +1172,7 @@ public:
         {\r
         type = TOK_FUNC_SUBSTRING_AFTER;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1089,7 +1185,7 @@ public:
         {\r
         type = TOK_FUNC_SUBSTRING;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1102,7 +1198,7 @@ public:
         {\r
         type = TOK_FUNC_STRING_LENGTH;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1115,7 +1211,7 @@ public:
         {\r
         type = TOK_FUNC_NORMALIZE_SPACE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1128,7 +1224,7 @@ public:
         {\r
         type = TOK_FUNC_TRANSLATE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1141,7 +1237,7 @@ public:
         {\r
         type = TOK_FUNC_BOOLEAN;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1154,7 +1250,7 @@ public:
         {\r
         type = TOK_FUNC_NOT;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1167,7 +1263,7 @@ public:
         {\r
         type = TOK_FUNC_TRUE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1180,7 +1276,7 @@ public:
         {\r
         type = TOK_FUNC_FALSE;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1193,7 +1289,7 @@ public:
         {\r
         type = TOK_FUNC_LANG;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1206,7 +1302,7 @@ public:
         {\r
         type = TOK_FUNC_NUMBER;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1219,7 +1315,7 @@ public:
         {\r
         type = TOK_FUNC_SUM;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1232,7 +1328,7 @@ public:
         {\r
         type = TOK_FUNC_FLOOR;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1245,7 +1341,7 @@ public:
         {\r
         type = TOK_FUNC_CEILING;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1258,7 +1354,7 @@ public:
         {\r
         type = TOK_FUNC_ROUND;\r
         }\r
-    virtual bool execute(Stack &stack)\r
+    virtual bool execute(TokenExecutor &exec)\r
         {\r
         return true;\r
         }\r
@@ -1316,10 +1412,9 @@ public:
     virtual void add(Token *tok);\r
 \r
     /**\r
-     *  This method "executes" a list of Tokens in the context of a DOM root\r
-     *  Node, returning a list of Nodes that match the xpath expression.\r
+     *\r
      */\r
-    NodeList execute(const Node *root);\r
+    virtual unsigned int size() const;\r
 \r
     /**\r
      *\r
@@ -1331,10 +1426,15 @@ private:
 \r
     std::vector<Token *> tokens;\r
 \r
+\r
 };\r
 \r
 \r
 \r
+\r
+\r
+\r
+\r
 } // namespace xpath\r
 } // namespace dom\r
 } // namespace w3c\r