public NodeTypeTest(Axes axis, XPathNodeType type, string param) : base(axis)
 {
     this.type   = type;
     this._param = param;
     if (param != null && type != XPathNodeType.ProcessingInstruction)
     {
         throw new XPathException("No argument allowed for " + NodeTypeTest.ToString(type) + "() test");
     }
 }
        public override string ToString()
        {
            string text = NodeTypeTest.ToString(this.type);

            if (this.type == XPathNodeType.ProcessingInstruction && this._param != null)
            {
                text = text + "('" + this._param + "')";
            }
            else
            {
                text += "()";
            }
            return(this._axis.ToString() + "::" + text);
        }
Exemple #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);
        }
 internal NodeTypeTest(NodeTypeTest other, Axes axis) : base(axis)
 {
     this.type   = other.type;
     this._param = other._param;
 }