/// <returns> The value represented by this xpath. Can only be evaluated when this xpath represents exactly one /// reference, or when it represents 0 references after a filtering operation (a reference which _could_ have /// existed, but didn't, rather than a reference which could not represent a real node). /// </returns> public override System.Object unpack() { lock (evaluated) { if (evaluated) { return(base.unpack()); } //this element is the important one. For Basic nodeset evaluations (referring to one node with no //multiplicites) we should be able to do this without doing the expansion //first, see if this treeref is usable without expansion int size = unExpandedRef.size(); bool safe = true;; for (int i = 0; i < size; ++i) { //We can't evaluated any predicates for sure if (unExpandedRef.getPredicate(i) != null) { safe = false; break; } int mult = unExpandedRef.getMultiplicity(i); if (!(mult >= 0 || mult == TreeReference.INDEX_UNBOUND)) { safe = false; break; } } if (!safe) { performEvaluation(); return(base.unpack()); } //TOOD: Evaluate error fallbacks, here. I don't know whether this handles the 0 case //the same way, although invalid multiplicities should be fine. try { //TODO: This doesn't handle templated nodes (repeats which may exist in the future) //figure out if we can roll that in easily. For now the catch handles it return(XPathPathExpr.getRefValue(instance, ec, unExpandedRef)); } catch (XPathException xpe) { //This isn't really a best effort attempt, so if we can, see if evaluating cleany works. performEvaluation(); return(base.unpack()); } } }
/// <returns> The value represented by this xpath. Can only be evaluated when this xpath represents exactly one /// reference, or when it represents 0 references after a filtering operation (a reference which _could_ have /// existed, but didn't, rather than a reference which could not represent a real node). /// </returns> public virtual System.Object unpack() { if (nodes == null) { throw InvalidNodesetException; } if (size() == 0) { return(XPathPathExpr.unpackValue(null)); } else if (size() > 1) { throw new XPathTypeMismatchException("This field is repeated: \n\n" + nodeContents() + "\n\nYou may need to use the indexed-repeat() function to specify which value you want."); } else { return(getValAt(0)); } }
public XPathReference(XPathPathExpr path) { ref_Renamed = path.getReference(); }
public virtual IConditionExpr refToPathExpr(TreeReference ref_Renamed) { return(new XPathConditional(XPathPathExpr.fromRef(ref_Renamed))); }
public virtual System.Object getValAt(int i) { return(XPathPathExpr.getRefValue(instance, ec, getRefAt(i))); }