Esempio n. 1
0
 private AxisIterator(AxisIterator other) : base(other)
 {
     _iter = (BaseIterator)other._iter.Clone();
     _test = other._test;
     //name = other.name;
     //ns = other.ns;
     //matchType = other.matchType;
 }
Esempio n. 2
0
        //string name, ns;
        //XPathNodeType matchType;

        public AxisIterator(BaseIterator iter, NodeTest test) : base(iter.NamespaceManager)
        {
            _iter = iter;
            _test = test;
            //test.GetInfo (out name, out ns, out matchType, NamespaceManager);
//			if (name != null)
//				name = Current.NameTable.Add (name);

//			if (ns != null)
//				ns = Current.NameTable.Add (ns);
        }
Esempio n. 3
0
        public override Expression Optimize()
        {
            this.left  = this.left.Optimize();
            this.right = (NodeSet)this.right.Optimize();
            NodeTest nodeTest = this.right as NodeTest;

            if (nodeTest != null && nodeTest.Axis.Axis == Axes.Child)
            {
                NodeNameTest nodeNameTest = nodeTest as NodeNameTest;
                if (nodeNameTest != null)
                {
                    return(new ExprSLASH(this.left, new NodeNameTest(nodeNameTest, Axes.Descendant)));
                }
                NodeTypeTest nodeTypeTest = nodeTest as NodeTypeTest;
                if (nodeTypeTest != null)
                {
                    return(new ExprSLASH(this.left, new NodeTypeTest(nodeTypeTest, Axes.Descendant)));
                }
            }
            return(this);
        }
Esempio n. 4
0
 internal XPathNodeIterator SelectTest(NodeTest test)
 {
     return(test.EvaluateNodeSet(new NullIterator(this)));
 }
Esempio n. 5
0
        public virtual bool Matches(XPathExpression expr)
        {
            Expression e = ((CompiledExpression)expr).ExpressionNode;

            if (e is ExprRoot)
            {
                return(NodeType == XPathNodeType.Root);
            }

            NodeTest nt = e as NodeTest;

            if (nt != null)
            {
                switch (nt.Axis.Axis)
                {
                case Axes.Child:
                case Axes.Attribute:
                    break;

                default:
                    throw new XPathException("Only child and attribute pattern are allowed for a pattern.");
                }
                return(nt.Match(((CompiledExpression)expr).NamespaceManager, this));
            }
            if (e is ExprFilter)
            {
                do
                {
                    e = ((ExprFilter)e).LeftHandSide;
                } while (e is ExprFilter);

                if (e is NodeTest && !((NodeTest)e).Match(((CompiledExpression)expr).NamespaceManager, this))
                {
                    return(false);
                }
            }

            XPathResultType resultType = e.ReturnType;

            switch (resultType)
            {
            case XPathResultType.Any:
            case XPathResultType.NodeSet:
                break;

            default:
                return(false);
            }

            switch (e.EvaluatedNodeType)
            {
            case XPathNodeType.Attribute:
            case XPathNodeType.Namespace:
                if (NodeType != e.EvaluatedNodeType)
                {
                    return(false);
                }
                break;
            }

            XPathNodeIterator nodes;

            nodes = this.Select(expr);
            while (nodes.MoveNext())
            {
                if (IsSamePosition(nodes.Current))
                {
                    return(true);
                }
            }

            // ancestors might select this node.

            XPathNavigator navigator = Clone();

            while (navigator.MoveToParent())
            {
                nodes = navigator.Select(expr);

                while (nodes.MoveNext())
                {
                    if (IsSamePosition(nodes.Current))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
 private AxisIterator(AxisIterator other) : base(other)
 {
     this._iter = (BaseIterator)other._iter.Clone();
     this._test = other._test;
 }
 public AxisIterator(BaseIterator iter, NodeTest test) : base(iter.NamespaceManager)
 {
     this._iter = iter;
     this._test = test;
 }