private EvaluationContext rescope(TreeReference treeRef, int currentContextPosition) { EvaluationContext ec = new EvaluationContext(this, treeRef); // broken: ec.currentContextPosition = currentContextPosition; //If there was no original context position, we'll want to set the next original //context to be this rescoping (which would be the backup original one). if (this.original != null) { ec.OriginalContext = this.OriginalContext; } else { //Check to see if we have a context, if not, the treeRef is the original declared //nodeset. if (TreeReference.rootRef().Equals(this.ContextRef)) { ec.OriginalContext = treeRef; } else { //If we do have a legit context, use it! ec.OriginalContext = this.ContextRef; } } return(ec); }
private void InitBlock() { this(base_Renamed, context); this.formInstances = formInstances; this(base_Renamed); this.formInstances = formInstances; this.instance = instance; this.formInstances = formInstances; this.instance = instance; this.contextNode = TreeReference.rootRef(); functionHandlers = new HashMap <String, IFunctionHandler>(); //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'" variables = new System.Collections.Hashtable(); for (String var: variables.keySet()) { //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'" setVariable(var, variables[var]); } return(expandReference(ref_Renamed, false)); if (!ref_Renamed.isAbsolute()) { return(null); } FormInstance baseInstance; if (ref_Renamed.getInstanceName() != null) { baseInstance = getInstance(ref_Renamed.getInstanceName()); } else { baseInstance = instance; } if (baseInstance == null) { throw new System.SystemException("Unable to expand reference " + ref_Renamed.toString(true) + ", no appropriate instance in evaluation context"); } List <TreeReference> v = new List <TreeReference>(); expandReference(ref_Renamed, baseInstance, baseInstance.getRoot().Ref, v, includeTemplates); return(v); int depth = workingRef.size(); //check to see if we've matched fully if (depth == sourceRef.size()) { //TODO: Do we need to clone these references? refs.addElement(workingRef); } else { //Otherwise, need to get the next set of matching references System.String name = sourceRef.getName(depth); predicates = sourceRef.getPredicate(depth); //Copy predicates for batch fetch if (predicates != null) { List <XPathExpression> predCopy = new List <XPathExpression>(); for (XPathExpression xpe: predicates) { predCopy.addElement(xpe); } predicates = predCopy; } //ETHERTON: Is this where we should test for predicates? int mult = sourceRef.getMultiplicity(depth); List <TreeReference> set = new List <TreeReference>(); TreeElement node = instance.resolveReference(workingRef); List <TreeReference> passingSet = new List <TreeReference>(); { if (node.NumChildren > 0) { if (mult == TreeReference.INDEX_UNBOUND) { int count = node.getChildMultiplicity(name); for (int i = 0; i < count; i++) { TreeElement child = node.getChild(name, i); if (child != null) { set_Renamed.addElement(child.Ref); } else { throw new System.SystemException("Missing or non-sequntial nodes expanding a reference"); // missing/non-sequential // nodes } } if (includeTemplates) { TreeElement template = node.getChild(name, TreeReference.INDEX_TEMPLATE); if (template != null) { set_Renamed.addElement(template.Ref); } } } else if (mult != TreeReference.INDEX_ATTRIBUTE) { //TODO: Make this test mult >= 0? //If the multiplicity is a simple integer, just get //the appropriate child TreeElement child = node.getChild(name, mult); if (child != null) { set_Renamed.addElement(child.Ref); } } } if (mult == TreeReference.INDEX_ATTRIBUTE) { TreeElement attribute = node.getAttribute(null, name); if (attribute != null) { set_Renamed.addElement(attribute.Ref); } } } if (predicates != null && predicateEvaluationProgress != null) { predicateEvaluationProgress[1] += set_Renamed.size(); } if (predicates != null) { bool firstTime = true; List <TreeReference> passed = new List <TreeReference>(); for (XPathExpression xpe: predicates) { for (int i = 0; i < set_Renamed.size(); ++i) { //if there are predicates then we need to see if e.nextElement meets the standard of the predicate TreeReference treeRef = set_Renamed.elementAt(i); //test the predicate on the treeElement EvaluationContext evalContext = rescope(treeRef, (firstTime?treeRef.MultLast:i)); System.Object o = xpe.eval(instance, evalContext); if (o is System.Boolean) { bool testOutcome = ((System.Boolean)o); if (testOutcome) { passed.addElement(treeRef); } } } firstTime = false; set_Renamed.clear(); set_Renamed.addAll(passed); passed.clear(); if (predicateEvaluationProgress != null) { predicateEvaluationProgress[0]++; } } } for (int i = 0; i < set_Renamed.size(); ++i) { TreeReference treeRef = set_Renamed.elementAt(i); expandReference(sourceRef, instance, treeRef, refs, includeTemplates); } } }