Example #1
0
        public LocationStep(string exp)
        {
            if (exp.IndexOf("::") > 0)
            {
                int    start    = exp.IndexOf("::");
                string axisSpec = exp.Substring(0, start);
                exp        = exp.Substring(start + 2);
                this._axis = AxisSpecifier.Find(axisSpec);
            }
            else
            {
                if (exp[0] == '@')
                {
                    this._axis = AxisSpecifier.Attribute;
                    exp        = exp.Substring(1);
                }
                else if (exp.Length >= 2 && exp.Substring(0, 2).Equals(".."))
                {
                    this._axis = AxisSpecifier.Parent;
                }
                else if (exp[0] == '.')
                {
                    this._axis = AxisSpecifier.Self;
                }
                else
                {
                    this._axis = AxisSpecifier.Child;
                }
            }
            this._predicates = new List <Predicate>();
            MatchCollection matches = predicateMatcher.Matches(exp);

            if (matches.Count > 0)
            {
                foreach (Match match in matches)
                {
                    this._predicates.Add(new Predicate(match.Value));
                }
                exp = exp.Substring(0, matches[0].Index);
            }
            if (this._axis == AxisSpecifier.Parent)
            {
                this._nodeTest = NodeTest.Create("*");
            }
            else
            {
                this._nodeTest = NodeTest.Create(exp);
            }
        }
Example #2
0
 /// <summary>
 /// Creates the standard AxisSpecifiers. This is all done privately and statically because the AxisSpecifiers
 /// are standardized to only certain values (see documentation at top of file).
 /// </summary>
 static AxisSpecifier()
 {
     AllSpecifiers    = new List <AxisSpecifier>();
     Child            = new AxisSpecifier(PrincipalNodeTypes.Element, "child", "");
     Attribute        = new AxisSpecifier(PrincipalNodeTypes.Attribute, "attribute", "@");
     Descendant       = new AxisSpecifier(PrincipalNodeTypes.Element, "descendant", "/");
     DescendantOrSelf = new AxisSpecifier(PrincipalNodeTypes.Element, "descendant-or-self", null);
     Parent           = new AxisSpecifier(PrincipalNodeTypes.Element, "parent", "..");
     Ancestor         = new AxisSpecifier(PrincipalNodeTypes.Element, "ancestor", null);
     AncestorOrSelf   = new AxisSpecifier(PrincipalNodeTypes.Element, "ancestor-or-self", null);
     Following        = new AxisSpecifier(PrincipalNodeTypes.Element, "following", null);
     Preceding        = new AxisSpecifier(PrincipalNodeTypes.Element, "preceding", null);
     FollowingSibling = new AxisSpecifier(PrincipalNodeTypes.Element, "following-sibling", null);
     PrecedingSibling = new AxisSpecifier(PrincipalNodeTypes.Element, "preceding-sibling", null);
     Self             = new AxisSpecifier(PrincipalNodeTypes.Element, "self", ".");
     Namespace        = new AxisSpecifier(PrincipalNodeTypes.Namespace, "namespace", null);
 }
Example #3
0
 /// <summary>
 /// Creates a new Location Step for a provided axis type and node test
 /// </summary>
 /// <param name="axis"></param>
 /// <param name="nodeTest"></param>
 public LocationStep(AxisSpecifier axis, NodeTest nodeTest)
 {
     this._axis       = axis;
     this._nodeTest   = nodeTest;
     this._predicates = new List <Predicate>();
 }