Ejemplo n.º 1
0
 internal ActiveAxis(Asttree axisTree)
 {
     _axisTree     = axisTree;                                           // only a pointer.  do i need it?
     _currentDepth = -1;                                                 // context depth is 0 -- enforce moveToChild for the context node
                                                                         // otherwise can't deal with "." node
     _axisStack = new ArrayList(axisTree.SubtreeArray.Count);            // defined length
     // new one stack element for each one
     for (int i = 0; i < axisTree.SubtreeArray.Count; ++i)
     {
         AxisStack stack = new AxisStack((ForwardAxis)axisTree.SubtreeArray[i], this);
         _axisStack.Add(stack);
     }
     _isActive = true;
 }
Ejemplo n.º 2
0
        // equal & ! attribute then move
        // "a/b/c"     pointer from a move to b
        // return true if reach c and c is an element and c is the axis
        internal bool MoveToChild(string name, string URN, int depth, ForwardAxis parent)
        {
            // an attribute can never be the same as an element
            if (Asttree.IsAttribute(this.curNode))
            {
                return(false);
            }

            // either moveToParent or moveToChild status will have to be changed into unmatch...
            if (this.isMatch)
            {
                this.isMatch = false;
            }
            if (!AxisStack.Equal(this.curNode.Name, this.curNode.Urn, name, URN))
            {
                return(false);
            }
            if (this.curDepth == -1)
            {
                SetDepth(depth);
            }
            else if (depth > this.curDepth)
            {
                return(false);
            }
            // matched ...
            if (this.curNode == parent.TopNode)
            {
                this.isMatch = true;
                return(true);
            }
            // move down this.curNode
            DoubleLinkAxis nowNode = (DoubleLinkAxis)(this.curNode.Next);

            if (Asttree.IsAttribute(nowNode))
            {
                this.isMatch = true;                    // for attribute
                return(false);
            }
            this.curNode = nowNode;
            this.curDepth++;
            return(false);
        }
Ejemplo n.º 3
0
        public bool MoveToStartElement(string localname, string URN)
        {
            if (!_isActive)
            {
                return(false);
            }

            // for each:
            _currentDepth++;
            bool result = false;

            for (int i = 0; i < _axisStack.Count; ++i)
            {
                AxisStack stack = (AxisStack)_axisStack[i];
                // special case for self tree   "." | ".//."
                if (stack.Subtree.IsSelfAxis)
                {
                    if (stack.Subtree.IsDss || (this.CurrentDepth == 0))
                    {
                        result = true;
                    }
                    continue;
                }

                // otherwise if it's context node then return false
                if (this.CurrentDepth == 0)
                {
                    continue;
                }

                if (stack.MoveToChild(localname, URN, _currentDepth))
                {
                    result = true;
                    // even already know the last result is true, still need to continue...
                    // run everyone once
                }
            }
            return(result);
        }