You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by ra...@apache.org on 2014/10/16 22:33:52 UTC

svn commit: r1632434 - /opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java

Author: ragerri
Date: Thu Oct 16 20:33:51 2014
New Revision: 1632434

URL: http://svn.apache.org/r1632434
Log:
OPENNLP-721 fixing xpath expression in GeneratorFactory

Modified:
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java?rev=1632434&r1=1632433&r2=1632434&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java Thu Oct 16 20:33:51 2014
@@ -31,6 +31,7 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
@@ -599,7 +600,6 @@ public class GeneratorFactory {
     } catch (SAXException e) {
       throw new InvalidFormatException("Descriptor is not valid XML!", e);
     }
-
     return xmlDescriptorDOM;
   }
 
@@ -640,10 +640,12 @@ public class GeneratorFactory {
     org.w3c.dom.Document xmlDescriptorDOM = createDOM(xmlDescriptorIn);
 
     XPath xPath = XPathFactory.newInstance().newXPath();
+    
 
     NodeList customElements;
     try {
-      customElements = (NodeList) xPath.evaluate("custom", xmlDescriptorDOM.getDocumentElement(), XPathConstants.NODESET);
+      XPathExpression exp = xPath.compile("//custom");
+      customElements = (NodeList) exp.evaluate(xmlDescriptorDOM.getDocumentElement(), XPathConstants.NODESET);
     } catch (XPathExpressionException e) {
       throw new IllegalStateException("The hard coded XPath expression should always be valid!");
     }
@@ -663,7 +665,6 @@ public class GeneratorFactory {
         }
       }
     }
-
     return mapping;
   }
 }