//TODO: merge anchor() and parent() public virtual TreeReference contextualize(TreeReference contextRef) { //TODO: Technically we should possibly be modifying context stuff here //instead of in the xpath stuff; if (!contextRef.Absolute) { return(null); } // I think contextualizing of absolute nodes still needs to be done. // They may contain predicates that need to be contextualized. TreeReference newRef = anchor(contextRef); // unclear... newRef.Context = contextRef.Context; //apply multiplicites and fill in wildcards as necessary based on the context ref for (int i = 0; i < contextRef.size() && i < newRef.size(); i++) { //If the the contextRef can provide a definition for a wildcard, do so if (TreeReference.NAME_WILDCARD.Equals(newRef.getName(i)) && !TreeReference.NAME_WILDCARD.Equals(contextRef.getName(i))) { newRef.data.setElementAt(newRef.data.elementAt(i).setName(contextRef.getName(i)), i); } if (contextRef.getName(i).Equals(newRef.getName(i))) { //We can't actually merge nodes if the newRef has predicates or filters //on this expression, since those reset any existing resolutions which //may have been done. if (newRef.getPredicate(i) == null) { newRef.setMultiplicity(i, contextRef.getMultiplicity(i)); } } else { break; } } return(newRef); }