f90952
From 8a9344f55d74a5b809051ae144b3c028499fec0d Mon Sep 17 00:00:00 2001
f90952
From: Mikolaj Izdebski <mizdebsk@redhat.com>
f90952
Date: Sat, 27 Sep 2013 10:53:46 +0200
f90952
Subject: [PATCH] Don't use Werken XPath
f90952
f90952
---
f90952
 src/java/org/apache/velocity/anakia/AnakiaElement.java |  7 +++++--
f90952
 src/java/org/apache/velocity/anakia/NodeList.java      |  6 ++++--
f90952
 src/java/org/apache/velocity/anakia/XPathCache.java    |  9 ++++++---
f90952
 src/java/org/apache/velocity/anakia/XPathTool.java     | 16 ++++++++++------
f90952
 4 files changed, 25 insertions(+), 13 deletions(-)
f90952
f90952
diff --git a/src/java/org/apache/velocity/anakia/AnakiaElement.java b/src/java/org/apache/velocity/anakia/AnakiaElement.java
f90952
index c72b653..df13153 100644
f90952
--- a/src/java/org/apache/velocity/anakia/AnakiaElement.java
f90952
+++ b/src/java/org/apache/velocity/anakia/AnakiaElement.java
f90952
@@ -20,8 +20,10 @@ package org.apache.velocity.anakia;
f90952
  */
f90952
 
f90952
 import org.jdom.Element;
f90952
+import org.jdom.JDOMException;
f90952
 import org.jdom.Namespace;
f90952
 import org.jdom.output.XMLOutputter;
f90952
+
f90952
 import java.util.List;
f90952
 
f90952
 /**
f90952
@@ -126,10 +128,11 @@ public class AnakiaElement extends Element
f90952
      * @param xpathExpression the XPath expression you wish to apply
f90952
      * @return a NodeList representing the nodes that are the result of
f90952
      * application of the XPath to the current element. It can be empty.
f90952
+     * @throws JDOMException
f90952
      */
f90952
-    public NodeList selectNodes(String xpathExpression)
f90952
+    public NodeList selectNodes(String xpathExpression) throws JDOMException
f90952
     {
f90952
-        return new NodeList(XPathCache.getXPath(xpathExpression).applyTo(this), false);
f90952
+        return new NodeList(XPathCache.getXPath(xpathExpression).selectNodes(this), false);
f90952
     }
f90952
 
f90952
     /**
f90952
diff --git a/src/java/org/apache/velocity/anakia/NodeList.java b/src/java/org/apache/velocity/anakia/NodeList.java
f90952
index daf611d..b303bda 100644
f90952
--- a/src/java/org/apache/velocity/anakia/NodeList.java
f90952
+++ b/src/java/org/apache/velocity/anakia/NodeList.java
f90952
@@ -35,6 +35,7 @@ import org.jdom.DocType;
f90952
 import org.jdom.Document;
f90952
 import org.jdom.Element;
f90952
 import org.jdom.EntityRef;
f90952
+import org.jdom.JDOMException;
f90952
 import org.jdom.ProcessingInstruction;
f90952
 import org.jdom.Text;
f90952
 import org.jdom.output.XMLOutputter;
f90952
@@ -289,10 +290,11 @@ public class NodeList implements List, Cloneable
f90952
      * @param xpathString the XPath expression you wish to apply
f90952
      * @return a NodeList representing the nodes that are the result of
f90952
      * application of the XPath to the current node list. It can be empty.
f90952
+     * @throws JDOMException
f90952
      */
f90952
-    public NodeList selectNodes(String xpathString)
f90952
+    public NodeList selectNodes(String xpathString) throws JDOMException
f90952
     {
f90952
-        return new NodeList(XPathCache.getXPath(xpathString).applyTo(nodes), false);
f90952
+        return new NodeList(XPathCache.getXPath(xpathString).selectNodes(nodes), false);
f90952
     }
f90952
 
f90952
 // List methods implemented hereafter
f90952
diff --git a/src/java/org/apache/velocity/anakia/XPathCache.java b/src/java/org/apache/velocity/anakia/XPathCache.java
f90952
index cef43d9..0d633b0 100644
f90952
--- a/src/java/org/apache/velocity/anakia/XPathCache.java
f90952
+++ b/src/java/org/apache/velocity/anakia/XPathCache.java
f90952
@@ -19,7 +19,9 @@ package org.apache.velocity.anakia;
f90952
  * under the License.    
f90952
  */
f90952
 
f90952
-import com.werken.xpath.XPath;
f90952
+import org.jdom.JDOMException;
f90952
+import org.jdom.xpath.XPath;
f90952
+
f90952
 import java.util.Map;
f90952
 import java.util.WeakHashMap;
f90952
 
f90952
@@ -46,8 +48,9 @@ class XPathCache
f90952
      * A cached object is returned if it already exists for the requested expression.
f90952
      * @param xpathString the XPath expression to parse
f90952
      * @return the XPath object that represents the parsed XPath expression.
f90952
+     * @throws JDOMException
f90952
      */
f90952
-    static XPath getXPath(String xpathString)
f90952
+    static XPath getXPath(String xpathString) throws JDOMException
f90952
     {
f90952
         XPath xpath = null;
f90952
         synchronized(XPATH_CACHE)
f90952
@@ -55,7 +58,7 @@ class XPathCache
f90952
             xpath = (XPath)XPATH_CACHE.get(xpathString);
f90952
             if(xpath == null)
f90952
             {
f90952
-                xpath = new XPath(xpathString);
f90952
+                xpath = XPath.newInstance(xpathString);
f90952
                 XPATH_CACHE.put(xpathString, xpath);
f90952
             }
f90952
         }
f90952
diff --git a/src/java/org/apache/velocity/anakia/XPathTool.java b/src/java/org/apache/velocity/anakia/XPathTool.java
f90952
index c9e6178..f85d2c1 100644
f90952
--- a/src/java/org/apache/velocity/anakia/XPathTool.java
f90952
+++ b/src/java/org/apache/velocity/anakia/XPathTool.java
f90952
@@ -23,6 +23,7 @@ import java.util.List;
f90952
 
f90952
 import org.jdom.Document;
f90952
 import org.jdom.Element;
f90952
+import org.jdom.JDOMException;
f90952
 
f90952
 /**
f90952
  * This class adds an entrypoint into XPath functionality,
f90952
@@ -88,12 +89,13 @@ public class XPathTool
f90952
      * @param doc The Document context
f90952
      *
f90952
      * @return A list of selected nodes
f90952
+     * @throws JDOMException
f90952
      */
f90952
     public NodeList applyTo(String xpathSpec,
f90952
-                        Document doc)
f90952
+                        Document doc) throws JDOMException
f90952
     {
f90952
         //RuntimeSingleton.info("XPathTool::applyTo(String, Document)");
f90952
-        return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( doc ), false);
f90952
+        return new NodeList(XPathCache.getXPath(xpathSpec).selectNodes( doc ), false);
f90952
     }
f90952
 
f90952
     /**
f90952
@@ -103,12 +105,13 @@ public class XPathTool
f90952
      * @param elem The Element context
f90952
      *
f90952
      * @return A list of selected nodes
f90952
+     * @throws JDOMException
f90952
      */
f90952
     public NodeList applyTo(String xpathSpec,
f90952
-                        Element elem)
f90952
+                        Element elem) throws JDOMException
f90952
     {
f90952
         //RuntimeSingleton.info("XPathTool::applyTo(String, Element)");
f90952
-        return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( elem ), false);
f90952
+        return new NodeList(XPathCache.getXPath(xpathSpec).selectNodes( elem ), false);
f90952
     }
f90952
 
f90952
     /**
f90952
@@ -118,12 +121,13 @@ public class XPathTool
f90952
      * @param nodeSet The nodeset context
f90952
      *
f90952
      * @return A list of selected nodes
f90952
+     * @throws JDOMException
f90952
      */
f90952
     public NodeList applyTo(String xpathSpec,
f90952
-                        List nodeSet)
f90952
+                        List nodeSet) throws JDOMException
f90952
     {
f90952
         //RuntimeSingleton.info("XPathTool::applyTo(String, List)");
f90952
-        return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( nodeSet ), false);
f90952
+        return new NodeList(XPathCache.getXPath(xpathSpec).selectNodes( nodeSet ), false);
f90952
     }
f90952
 }
f90952
 
f90952
-- 
f90952
1.8.3.1
f90952