FOP-3053: Reduce use of xalan

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1898051 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java b/fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java
index e01271f..40eb722 100644
--- a/fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java
@@ -36,6 +36,10 @@
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -46,8 +50,6 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.xpath.XPathAPI;
-import org.apache.xpath.objects.XObject;
 
 import org.apache.xmlgraphics.io.Resource;
 import org.apache.xmlgraphics.io.ResourceResolver;
@@ -155,14 +157,9 @@
         return doc;
     }
 
-    private String evalXPath(Document doc, String xpath) {
-        XObject res;
-        try {
-            res = XPathAPI.eval(doc, xpath);
-        } catch (TransformerException e) {
-            throw new RuntimeException("XPath evaluation failed: " + e.getMessage());
-        }
-        return res.str();
+    private String evalXPath(Document doc, String xpath) throws XPathExpressionException {
+        XPath xPath = XPathFactory.newInstance().newXPath();
+        return (String) xPath.compile(xpath).evaluate(doc, XPathConstants.STRING);
     }
 
     /**
diff --git a/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java b/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java
index 4f56f9c..901bef2 100644
--- a/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java
+++ b/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java
@@ -35,13 +35,14 @@
 import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import org.apache.xpath.XPathAPI;
-import org.apache.xpath.objects.XObject;
-
 import org.apache.fop.apps.EnvironmentProfile;
 import org.apache.fop.apps.EnvironmentalProfileFactory;
 import org.apache.fop.apps.FopFactory;
@@ -128,33 +129,36 @@
 
     private boolean isBase14KerningEnabled(Document testDoc) {
         try {
-            XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/base14kerning");
-            String s = xo.str();
+            String s = eval(testDoc, "/testcase/cfg/base14kerning");
             return ("true".equalsIgnoreCase(s));
-        } catch (TransformerException e) {
+        } catch (XPathExpressionException e) {
             throw new RuntimeException("Error while evaluating XPath expression", e);
         }
     }
 
     private boolean isStrictValidation(Document testDoc) {
         try {
-            XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/strict-validation");
-            return !("false".equalsIgnoreCase(xo.str()));
-        } catch (TransformerException e) {
+            String s = eval(testDoc, "/testcase/cfg/strict-validation");
+            return !("false".equalsIgnoreCase(s));
+        } catch (XPathExpressionException e) {
             throw new RuntimeException("Error while evaluating XPath expression", e);
         }
     }
 
     private boolean isTableBorderOverpaint(Document testDoc) {
         try {
-            XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/table-border-overpaint");
-            String s = xo.str();
+            String s = eval(testDoc, "/testcase/cfg/table-border-overpaint");
             return "true".equalsIgnoreCase(s);
-        } catch (TransformerException e) {
+        } catch (XPathExpressionException e) {
             throw new RuntimeException("Error while evaluating XPath expression", e);
         }
     }
 
+    private String eval(Document doc, String xpath) throws XPathExpressionException {
+        XPath xPath = XPathFactory.newInstance().newXPath();
+        return (String) xPath.compile(xpath).evaluate(doc, XPathConstants.STRING);
+    }
+
     /**
      * Loads a test case into a DOM document.
      * @param testFile the test file