public override object visit(XPathExpr e) { if (e.slashes() > 0) { throw new XPathParserException("Access to root node is not allowed (set by caller)"); } do { e.expr().accept(this); // check the single step (may have filter with root access) e = e.next(); // follow singly linked list of the path, it's all relative past the first one } while (e != null); return(null); }
/// <summary> /// Validate an xpath expression. /// </summary> /// <param name="e"> /// is the expression. </param> /// <returns> null. </returns> public virtual object visit(XPathExpr e) { XPathExpr xp = e; bool firstStep = true; while (xp != null) { if (firstStep && xp.slashes() != 0) { _rootUsed = true; } firstStep = false; StepExpr se = xp.expr(); if (se != null) { se.accept(this); } xp = xp.next(); } return(null); }
/// <param name="e"> /// is the xpath expression. </param> /// <returns> result. </returns> public virtual object visit(XPathExpr e) { e.expr().accept(this); e.next().accept(this); return(null); }
/// <param name="e"> /// is the xpath expression. </param> /// <returns> result. </returns> public virtual object visit(XPathExpr e) { XPathExpr xp = e; int depth = 0; // indicates how many / we traversed XPathExpr result = e; while (xp != null) { int slashes = xp.slashes(); StepExpr se = xp.expr(); if (slashes == 1) { // this is a single slash and nothing else... if (se == null) { return(make_root_self_node()); } // /RelativePathExpr if (depth == 0) { XPathExpr xpe = make_root_self_node(); xpe.set_next(e); result = xpe; } } if (slashes == 2) { // //RelativePathExpr if (depth == 0) { XPathExpr desc = make_descendant_or_self(); desc.set_slashes(1); e.set_slashes(1); desc.set_next(e); XPathExpr root_self = make_root_self_node(); root_self.set_next(desc); return(root_self); } } if (se != null) { se.accept(this); } XPathExpr next = xp.next(); // peek if the next guy will have 2 slashes... if (next != null) { // StepExpr//StepExpr if (next.slashes() == 2) { // create the node to stick between the // slashes XPathExpr desc = make_descendant_or_self(); desc.set_slashes(1); // current node / desc / next xp.set_next(desc); desc.set_next(next); next.set_slashes(1); } } xp = next; depth++; } return(result); }