示例#1
0
 // "a/b/c"     pointer from b move to a
 // needn't change even tree structure changes
 internal void MoveToParent(int depth, ForwardAxis parent) {
     // "a/b/c", trying to match b (current node), but meet the end of a, so move pointer to a
     if ( depth == this.curDepth - 1 ) {
         // really need to move the current node pointer to parent
         // what i did here is for seperating the case of IsDss or only IsChild
         // bcoz in the first case i need to expect "a" from random depth
         // -1 means it doesn't expect some specific depth (referecing the dealing to -1 in movetochild method
         // while in the second case i can't change the root depth which is 1.
         if ((this.curNode.Input == parent.RootNode ) && (parent.IsDss)) {
             this.curNode = parent.RootNode;
             this.rootDepth = this.curDepth = -1;
             return;
         }
         else if (this.curNode.Input != null) {      // else cur-depth --, cur-node change
             this.curNode = (DoubleLinkAxis) (this.curNode.Input);
             this.curDepth --;
             return;
         }
         else return;
     }
     // "a/b/c", trying to match b (current node), but meet the end of x (another child of a)
     // or maybe i matched, now move out the current node
     // or move out after failing to match attribute
     // the node i m next expecting is still the current node
     else if (depth == this.curDepth) {              // after matched or [2] failed in matching attribute
         if (this.isMatch) {
             this.isMatch = false;   
         }
     }
     return;                                         // this node is still what i am expecting
     // ignore
 }
示例#2
0
文件: Asttree.cs 项目: chcosta/corefx
        // 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;
        }
示例#3
0
文件: Asttree.cs 项目: chcosta/corefx
 public ForwardAxis(DoubleLinkAxis axis, bool isdesorself)
 {
     _isDss = isdesorself;
     _isAttribute = Asttree.IsAttribute(axis);
     _topNode = axis;
     _rootNode = axis;
     while (_rootNode.Input != null)
     {
         _rootNode = (DoubleLinkAxis)(_rootNode.Input);
     }
     // better to calculate it out, since it's used so often, and if the top is self then the whole tree is self
     _isSelfAxis = Asttree.IsSelf(_topNode);
 }
示例#4
0
文件: Asttree.cs 项目: chcosta/corefx
 //constructor
 internal DoubleLinkAxis(Axis axis, DoubleLinkAxis inputaxis)
     : base(axis.TypeOfAxis, inputaxis, axis.Prefix, axis.Name, axis.NodeType)
 {
     this.next = null;
     this.Urn = axis.Urn;
     this.abbrAxis = axis.AbbrAxis;
     if (inputaxis != null)
     {
         inputaxis.Next = this;
     }
 }
示例#5
0
文件: Asttree.cs 项目: chcosta/corefx
 // constructor
 internal AxisElement(DoubleLinkAxis node, int depth)
 {
     this.curNode = node;
     this.rootDepth = this.curDepth = depth;
     this.isMatch = false;
 }
示例#6
0
文件: asttree.cs 项目: ArildF/masters
 //constructor
 internal DoubleLinkAxis (Axis axis, DoubleLinkAxis inputaxis) {
     this.next = null;
     this._input = inputaxis;
     this._urn = axis.URN;
     this._prefix = axis.Prefix;
     this._name = axis.Name;
     this._nodetype = axis.Type;
     this._axistype = axis.TypeOfAxis;
     this.abbrAxis = axis.abbrAxis;
     if (inputaxis != null) {
         inputaxis.Next = this;
     }
 }