コード例 #1
0
 internal DoubleLinkAxis(Axis axis, DoubleLinkAxis inputaxis) : base(axis.TypeOfAxis, inputaxis, axis.Prefix, axis.Name, axis.NodeType)
 {
     this.next     = null;
     base.Urn      = axis.Urn;
     base.abbrAxis = axis.AbbrAxis;
     if (inputaxis != null)
     {
         inputaxis.Next = this;
     }
 }
コード例 #2
0
 public ForwardAxis(DoubleLinkAxis axis, bool isdesorself)
 {
     this.isDss       = isdesorself;
     this.isAttribute = Asttree.IsAttribute(axis);
     this.topNode     = axis;
     this.rootNode    = axis;
     while (this.rootNode.Input != null)
     {
         this.rootNode = (DoubleLinkAxis)this.rootNode.Input;
     }
     this.isSelfAxis = Asttree.IsSelf(this.topNode);
 }
コード例 #3
0
 public ForwardAxis(DoubleLinkAxis axis, bool isdesorself)
 {
     this.isDss = isdesorself;
     this.isAttribute = Asttree.IsAttribute(axis);
     this.topNode = axis;
     this.rootNode = axis;
     while (this.rootNode.Input != null)
     {
         this.rootNode = (DoubleLinkAxis) this.rootNode.Input;
     }
     this.isSelfAxis = Asttree.IsSelf(this.topNode);
 }
コード例 #4
0
ファイル: Asttree.cs プロジェクト: pedrobsaila/runtime
 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);
 }
コード例 #5
0
ファイル: Asttree.cs プロジェクト: pedrobsaila/runtime
        // 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);
        }
コード例 #6
0
 internal void MoveToParent(int depth, ForwardAxis parent)
 {
     if (depth == (this.curDepth - 1))
     {
         if ((this.curNode.Input == parent.RootNode) && parent.IsDss)
         {
             this.curNode = parent.RootNode;
             this.rootDepth = this.curDepth = -1;
         }
         else if (this.curNode.Input != null)
         {
             this.curNode = (DoubleLinkAxis) this.curNode.Input;
             this.curDepth--;
         }
     }
     else if ((depth == this.curDepth) && this.isMatch)
     {
         this.isMatch = false;
     }
 }
コード例 #7
0
        // only for debug
#if DEBUG
        public void PrintTree(StreamWriter msw)
        {
            foreach (ForwardAxis axis in fAxisArray)
            {
                msw.WriteLine("<Tree IsDss=\"{0}\" IsAttribute=\"{1}\">", axis.IsDss, axis.IsAttribute);
                DoubleLinkAxis printaxis = axis.TopNode;
                while (printaxis != null)
                {
                    msw.WriteLine(" <node>");
                    msw.WriteLine("  <URN> {0} </URN>", printaxis.Urn);
                    msw.WriteLine("  <Prefix> {0} </Prefix>", printaxis.Prefix);
                    msw.WriteLine("  <Name> {0} </Name>", printaxis.Name);
                    msw.WriteLine("  <NodeType> {0} </NodeType>", printaxis.NodeType);
                    msw.WriteLine("  <AxisType> {0} </AxisType>", printaxis.TypeOfAxis);
                    msw.WriteLine(" </node>");
                    printaxis = (DoubleLinkAxis)(printaxis.Input);
                }
                msw.WriteLine("</Tree>");
            }
        }
コード例 #8
0
 internal void MoveToParent(int depth, ForwardAxis parent)
 {
     if (depth == (this.curDepth - 1))
     {
         if ((this.curNode.Input == parent.RootNode) && parent.IsDss)
         {
             this.curNode   = parent.RootNode;
             this.rootDepth = this.curDepth = -1;
         }
         else if (this.curNode.Input != null)
         {
             this.curNode = (DoubleLinkAxis)this.curNode.Input;
             this.curDepth--;
         }
     }
     else if ((depth == this.curDepth) && this.isMatch)
     {
         this.isMatch = false;
     }
 }
コード例 #9
0
ファイル: Asttree.cs プロジェクト: pedrobsaila/runtime
 // "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
 }
コード例 #10
0
 internal bool MoveToChild(string name, string URN, int depth, ForwardAxis parent)
 {
     if (!Asttree.IsAttribute(this.curNode))
     {
         if (this.isMatch)
         {
             this.isMatch = false;
         }
         if (!AxisStack.Equal(this.curNode.Name, this.curNode.Urn, name, URN))
         {
             return false;
         }
         if (this.curDepth == -1)
         {
             this.SetDepth(depth);
         }
         else if (depth > this.curDepth)
         {
             return false;
         }
         if (this.curNode == parent.TopNode)
         {
             this.isMatch = true;
             return true;
         }
         DoubleLinkAxis next = (DoubleLinkAxis) this.curNode.Next;
         if (Asttree.IsAttribute(next))
         {
             this.isMatch = true;
             return false;
         }
         this.curNode = next;
         this.curDepth++;
     }
     return false;
 }
コード例 #11
0
 internal bool MoveToChild(string name, string URN, int depth, ForwardAxis parent)
 {
     if (!Asttree.IsAttribute(this.curNode))
     {
         if (this.isMatch)
         {
             this.isMatch = false;
         }
         if (!AxisStack.Equal(this.curNode.Name, this.curNode.Urn, name, URN))
         {
             return(false);
         }
         if (this.curDepth == -1)
         {
             this.SetDepth(depth);
         }
         else if (depth > this.curDepth)
         {
             return(false);
         }
         if (this.curNode == parent.TopNode)
         {
             this.isMatch = true;
             return(true);
         }
         DoubleLinkAxis next = (DoubleLinkAxis)this.curNode.Next;
         if (Asttree.IsAttribute(next))
         {
             this.isMatch = true;
             return(false);
         }
         this.curNode = next;
         this.curDepth++;
     }
     return(false);
 }
コード例 #12
0
ファイル: Asttree.cs プロジェクト: pedrobsaila/runtime
        // don't return true or false, if it's invalid path, just throw exception during the process
        // for whitespace thing, i will directly trim the tree built here...
        public void CompileXPath(string xPath, bool isField, XmlNamespaceManager nsmgr)
        {
            if ((xPath == null) || (xPath.Length == 0))
            {
                throw new XmlSchemaException(SR.Sch_EmptyXPath, string.Empty);
            }

            // firstly i still need to have an ArrayList to store tree only...
            // can't new ForwardAxis right away
            string[]  xpath    = xPath.Split('|');
            ArrayList AstArray = new ArrayList(xpath.Length);

            _fAxisArray = new ArrayList(xpath.Length);

            // throw compile exceptions
            // can i only new one builder here then run compile several times??
            try
            {
                for (int i = 0; i < xpath.Length; ++i)
                {
                    // default ! isdesorself (no .//)
                    Axis ast = (Axis)(XPathParser.ParseXPathExpression(xpath[i]));
                    AstArray.Add(ast);
                }
            }
            catch
            {
                throw new XmlSchemaException(SR.Sch_ICXpathError, xPath);
            }

            Axis?stepAst;

            for (int i = 0; i < AstArray.Count; ++i)
            {
                Axis ast = (Axis)AstArray[i] !;
                // Restricted form
                // field can have an attribute:

                // throw exceptions during casting
                if ((stepAst = ast) == null)
                {
                    throw new XmlSchemaException(SR.Sch_ICXpathError, xPath);
                }

                Axis top = stepAst;

                // attribute will have namespace too
                // field can have top attribute
                if (IsAttribute(stepAst))
                {
                    if (!isField)
                    {
                        throw new XmlSchemaException(SR.Sch_SelectorAttr, xPath);
                    }
                    else
                    {
                        SetURN(stepAst, nsmgr);
                        try
                        {
                            stepAst = (Axis?)(stepAst.Input);
                        }
                        catch
                        {
                            throw new XmlSchemaException(SR.Sch_ICXpathError, xPath);
                        }
                    }
                }

                // field or selector
                while ((stepAst != null) && (IsNameTest(stepAst) || IsSelf(stepAst)))
                {
                    // trim tree "." node, if it's not the top one
                    if (IsSelf(stepAst) && (ast != stepAst))
                    {
                        top.Input = stepAst.Input;
                    }
                    else
                    {
                        top = stepAst;
                        // set the URN
                        if (IsNameTest(stepAst))
                        {
                            SetURN(stepAst, nsmgr);
                        }
                    }
                    try
                    {
                        stepAst = (Axis?)(stepAst.Input);
                    }
                    catch
                    {
                        throw new XmlSchemaException(SR.Sch_ICXpathError, xPath);
                    }
                }

                // the rest part can only be .// or null
                // trim the rest part, but need compile the rest part first
                top.Input = null;
                if (stepAst == null)
                {      // top "." and has other element beneath, trim this "." node too
                    if (IsSelf(ast) && (ast.Input != null))
                    {
                        _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree((Axis)(ast.Input)), false));
                    }
                    else
                    {
                        _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree(ast), false));
                    }
                    continue;
                }
                if (!IsDescendantOrSelf(stepAst))
                {
                    throw new XmlSchemaException(SR.Sch_ICXpathError, xPath);
                }
                try
                {
                    stepAst = (Axis?)(stepAst.Input);
                }
                catch
                {
                    throw new XmlSchemaException(SR.Sch_ICXpathError, xPath);
                }
                if ((stepAst == null) || (!IsSelf(stepAst)) || (stepAst.Input != null))
                {
                    throw new XmlSchemaException(SR.Sch_ICXpathError, xPath);
                }

                // trim top "." if it's not the only node
                if (IsSelf(ast) && (ast.Input != null))
                {
                    _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree((Axis)(ast.Input)), true));
                }
                else
                {
                    _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree(ast), true));
                }
            }
        }
コード例 #13
0
ファイル: Asttree.cs プロジェクト: pedrobsaila/runtime
 // constructor
 internal AxisElement(DoubleLinkAxis node, int depth)
 {
     this.curNode   = node;
     this.rootDepth = this.curDepth = depth;
     this.isMatch   = false;
 }
コード例 #14
0
 internal AxisElement(DoubleLinkAxis node, int depth)
 {
     this.curNode = node;
     this.rootDepth = this.curDepth = depth;
     this.isMatch = false;
 }
コード例 #15
0
        public void CompileXPath(string xPath, bool isField, XmlNamespaceManager nsmgr)
        {
            if ((xPath == null) || (xPath.Length == 0))
            {
                throw new XmlSchemaException("Sch_EmptyXPath", string.Empty);
            }
            string[]  strArray = xPath.Split(new char[] { '|' });
            ArrayList list     = new ArrayList(strArray.Length);

            this.fAxisArray = new ArrayList(strArray.Length);
            try
            {
                for (int j = 0; j < strArray.Length; j++)
                {
                    Axis axis = (Axis)XPathParser.ParseXPathExpresion(strArray[j]);
                    list.Add(axis);
                }
            }
            catch
            {
                throw new XmlSchemaException("Sch_ICXpathError", xPath);
            }
            for (int i = 0; i < list.Count; i++)
            {
                Axis ast   = (Axis)list[i];
                Axis input = ast;
                if (input == null)
                {
                    throw new XmlSchemaException("Sch_ICXpathError", xPath);
                }
                Axis axis4 = input;
                if (!IsAttribute(input))
                {
                    goto Label_013D;
                }
                if (!isField)
                {
                    throw new XmlSchemaException("Sch_SelectorAttr", xPath);
                }
                this.SetURN(input, nsmgr);
                try
                {
                    input = (Axis)input.Input;
                    goto Label_013D;
                }
                catch
                {
                    throw new XmlSchemaException("Sch_ICXpathError", xPath);
                }
Label_00EB:
                if (IsSelf(input) && (ast != input))
                {
                    axis4.Input = input.Input;
                }
                else
                {
                    axis4 = input;
                    if (IsNameTest(input))
                    {
                        this.SetURN(input, nsmgr);
                    }
                }
                try
                {
                    input = (Axis)input.Input;
                }
                catch
                {
                    throw new XmlSchemaException("Sch_ICXpathError", xPath);
                }
Label_013D:
                if ((input != null) && (IsNameTest(input) || IsSelf(input)))
                {
                    goto Label_00EB;
                }
                axis4.Input = null;
                if (input == null)
                {
                    if (IsSelf(ast) && (ast.Input != null))
                    {
                        this.fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree((Axis)ast.Input), false));
                    }
                    else
                    {
                        this.fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree(ast), false));
                    }
                }
                else
                {
                    if (!IsDescendantOrSelf(input))
                    {
                        throw new XmlSchemaException("Sch_ICXpathError", xPath);
                    }
                    try
                    {
                        input = (Axis)input.Input;
                    }
                    catch
                    {
                        throw new XmlSchemaException("Sch_ICXpathError", xPath);
                    }
                    if (((input == null) || !IsSelf(input)) || (input.Input != null))
                    {
                        throw new XmlSchemaException("Sch_ICXpathError", xPath);
                    }
                    if (IsSelf(ast) && (ast.Input != null))
                    {
                        this.fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree((Axis)ast.Input), true));
                    }
                    else
                    {
                        this.fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree(ast), true));
                    }
                }
            }
        }