abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r448233 - /incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
Date Wed, 20 Sep 2006 15:14:42 GMT
Author: jmsnell
Date: Wed Sep 20 08:14:42 2006
New Revision: 448233

URL: http://svn.apache.org/viewvc?view=rev&rev=448233
Log:
The default function and variable contexts were being overwritten causing the standard xpath
functions
like count and concat to be lost. Thanks to Hugo Duncan for pointing it out.

Modified:
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java?view=diff&rev=448233&r1=448232&r2=448233
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
Wed Sep 20 08:14:42 2006
@@ -84,8 +84,10 @@
     return getXPath(path, null);
   }
   
-  private static FunctionContext getFunctionContext(Map<QName,Function> functions)
{
-    SimpleFunctionContext context = new SimpleFunctionContext();
+  private static FunctionContext getFunctionContext(
+    Map<QName,Function> functions,
+    SimpleFunctionContext context) {
+    if (context == null) context = new SimpleFunctionContext();
     for (QName qname : functions.keySet()) {
       Function function = functions.get(qname);
       context.registerFunction(
@@ -96,8 +98,10 @@
     return context;
   }
   
-  private static VariableContext getVariableContext(Map<QName,Object> variables) {
-    SimpleVariableContext context = new SimpleVariableContext();
+  private static VariableContext getVariableContext(
+    Map<QName,Object> variables,
+    SimpleVariableContext context) {
+    if (context == null) context = new SimpleVariableContext();
     for (QName qname : variables.keySet()) {
       Object value = variables.get(qname);
       context.setVariableValue(
@@ -121,10 +125,17 @@
         contextpath.addNamespace(entry.getKey(), entry.getValue());
       }
     }
-    if (functions != null)
-      contextpath.setFunctionContext(getFunctionContext(functions));
+    if (functions != null) {
+      contextpath.setFunctionContext(
+        getFunctionContext(
+          functions,
+          (SimpleFunctionContext)contextpath.getFunctionContext()));
+    }
     if (variables != null)
-      contextpath.setVariableContext(getVariableContext(variables));
+      contextpath.setVariableContext(
+        getVariableContext(
+          variables,
+          (SimpleVariableContext)contextpath.getVariableContext()));
     return contextpath;    
   }
   



Mime
View raw message