示例#1
0
 public XPathAxis(CodePlex.XPathParser.XPathAxis axis, XPathNodeType nodeType, string prefix, string name, string nodeTest)
 {
     this.Axis     = axis;
     this.NodeType = nodeType;
     this.Prefix   = prefix;
     this.Name     = name;
     this.NodeTest = nodeTest;
 }
示例#2
0
        public string Axis(CodePlex.XPathParser.XPathAxis axis, XPathNodeType nodeType, string prefix, string name)
        {
            string    nodeTest;
            XPathAxis xPathAxis;
            var       createAxis = false;

            switch (nodeType)
            {
            case XPathNodeType.ProcessingInstruction:
                Debug.Assert(prefix == "");
                nodeTest = "processing-instruction(" + name + ")";
                break;

            case XPathNodeType.Text:
                Debug.Assert(prefix == null && name == null);
                nodeTest = "text()";
                break;

            case XPathNodeType.Comment:
                Debug.Assert(prefix == null && name == null);
                nodeTest = "comment()";
                break;

            case XPathNodeType.All:
                nodeTest   = "node()";
                createAxis = true;
                break;

            case XPathNodeType.Attribute:

                lastAttribute = new XPathAttribute(name);
                nodeTest      = QNameOrWildcard(prefix, name);

                operandQueue.Enqueue(lastAttribute);

                break;

            case XPathNodeType.Element:

                if (lastElement != null)
                {
                    CreateElement();
                }

                lastElement = name;
                nodeTest    = QNameOrWildcard(prefix, name);

                break;

            case XPathNodeType.Namespace:
                nodeTest = QNameOrWildcard(prefix, name);
                break;

            default:
                throw new ArgumentException("unexpected XPathNodeType", "XPathNodeType");
            }

            if (createAxis)
            {
                xPathAxis = new XPathAxis(axis, nodeType, prefix, name, nodeTest);
                this.PartQueue.Enqueue(xPathAxis);
            }

            return(axisStrings[(int)axis] + nodeTest);
        }