Project

Profile

Help

Patch #1841 ยป saxonPatch.txt

Stuart Barker, 2013-07-12 14:07

 
### Eclipse Workspace Patch 1.0
#P Saxon-HE_latest9.5
Index: hej/net/sf/saxon/s9api/XPathExecutable.java
===================================================================
--- hej/net/sf/saxon/s9api/XPathExecutable.java (revision 851)
+++ hej/net/sf/saxon/s9api/XPathExecutable.java (working copy)
@@ -8,12 +8,14 @@
package net.sf.saxon.s9api;
import net.sf.saxon.expr.StaticContext;
+import net.sf.saxon.om.StructuredQName;
import net.sf.saxon.sxpath.IndependentContext;
import net.sf.saxon.sxpath.XPathExpression;
import net.sf.saxon.sxpath.XPathVariable;
-import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
/**
* An XPathExecutable represents the compiled form of an XPath expression.
@@ -49,10 +51,10 @@
*/
public XPathSelector load() {
- ArrayList<XPathVariable> declaredVariables = new ArrayList<XPathVariable>();
+ Map<StructuredQName, XPathVariable> declaredVariables = new LinkedHashMap<StructuredQName, XPathVariable>();
for (Iterator iter=env.iterateExternalVariables(); iter.hasNext();) {
XPathVariable var = (XPathVariable)iter.next();
- declaredVariables.add(var);
+ declaredVariables.put(var.getVariableQName(), var);
}
return new XPathSelector(exp, declaredVariables);
}
Index: hej/net/sf/saxon/s9api/XPathSelector.java
===================================================================
--- hej/net/sf/saxon/s9api/XPathSelector.java (revision 851)
+++ hej/net/sf/saxon/s9api/XPathSelector.java (working copy)
@@ -17,9 +17,8 @@
import net.sf.saxon.value.SequenceExtent;
import javax.xml.transform.URIResolver;
-import java.util.ArrayList;
import java.util.Iterator;
-import java.util.List;
+import java.util.Map;
/**
* An XPathSelector represents a compiled and loaded XPath expression ready for execution.
@@ -30,12 +29,12 @@
private XPathExpression exp;
private XPathDynamicContext dynamicContext;
- private List<XPathVariable> declaredVariables;
+ private Map<StructuredQName, XPathVariable> declaredVariables;
// protected constructor
protected XPathSelector(XPathExpression exp,
- ArrayList<XPathVariable> declaredVariables) {
+ Map<StructuredQName, XPathVariable> declaredVariables) {
this.exp = exp;
this.declaredVariables = declaredVariables;
dynamicContext = exp.createDynamicContext();
@@ -88,14 +87,8 @@
*/
public void setVariable(QName name, XdmValue value) throws SaxonApiException {
- XPathVariable var = null;
StructuredQName qn = name.getStructuredQName();
- for (XPathVariable v : declaredVariables) {
- if (v.getVariableQName().equals(qn)) {
- var = v;
- break;
- }
- }
+ XPathVariable var = declaredVariables.get(qn);
if (var == null) {
throw new SaxonApiException(
new XPathException("Variable has not been declared: " + name));
    (1-1/1)