public static XPathPathExpr fromRef(TreeReference out_) { XPathPathExpr path = new XPathPathExpr(); path.init_context = (out_.isAbsolute() ? INIT_CONTEXT_ROOT : INIT_CONTEXT_RELATIVE); path.steps = new XPathStep[out_.size()]; for (int i = 0; i < path.steps.Length; i++) { if (out_.getName(i).Equals(TreeReference.NAME_WILDCARD)) { path.steps[i] = new XPathStep(XPathStep.AXIS_CHILD, XPathStep.TEST_NAME_WILDCARD); } else { path.steps[i] = new XPathStep(XPathStep.AXIS_CHILD, new XPathQName(out_.getName(i))); } } return(path); }
public override object eval(FormInstance m, EvaluationContext evalContext) { TreeReference genericRef = getReference(); if (genericRef.isAbsolute() && m.getTemplatePath(genericRef) == null) { throw new XPathTypeMismatchException("Node " + genericRef.toString() + " does not exist!"); } TreeReference ref_ = genericRef.contextualize(evalContext.ContextRef); List <TreeReference> nodesetRefs = m.expandReference(ref_); //to fix conditions based on non-relevant data, filter the nodeset by relevancy for (int i = 0; i < nodesetRefs.Count; i++) { if (!m.resolveReference((TreeReference)nodesetRefs[i]).isRelevant()) { nodesetRefs.RemoveAt(i); i--; } } return(new XPathNodeset(nodesetRefs, m, evalContext)); }