From: <bo...@us...> - 2007-05-01 11:41:21
|
Revision: 205 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=205&view=rev Author: bodewig Date: 2007-05-01 04:41:21 -0700 (Tue, 01 May 2007) Log Message: ----------- Make XPathFactory configurable Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2007-05-01 10:47:53 UTC (rev 204) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2007-05-01 11:41:21 UTC (rev 205) @@ -76,6 +76,7 @@ private static boolean normalizeWhitespace = false; private static boolean ignoreAttributeOrder = false; private static String xsltVersion = "1.0"; + private static String xpathFactoryName = null; private static final String XSLT_VERSION_START = " version=\""; private static final String XSLT_VERSION_END = "\">"; @@ -744,6 +745,20 @@ } /** + * Sets the class to use as XPathFactory when using JAXP 1.3. + */ + public static void setXPathFactory(String className) { + xpathFactoryName = className; + } + + /** + * Gets the class to use as XPathFactory when using JAXP 1.3. + */ + public static String getXPathFactory() { + return xpathFactoryName; + } + + /** * XSLT stylesheet element using the configured XSLT version. */ static String getXSLTStart() { Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2007-05-01 10:47:53 UTC (rev 204) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2007-05-01 11:41:21 UTC (rev 205) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2006-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -36,10 +36,11 @@ package org.custommonkey.xmlunit.jaxp13; +import org.custommonkey.xmlunit.NamespaceContext; +import org.custommonkey.xmlunit.XMLUnit; +import org.custommonkey.xmlunit.XpathEngine; import org.custommonkey.xmlunit.exceptions.ConfigurationException; import org.custommonkey.xmlunit.exceptions.XpathException; -import org.custommonkey.xmlunit.NamespaceContext; -import org.custommonkey.xmlunit.XpathEngine; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; @@ -59,7 +60,15 @@ public Jaxp13XpathEngine() throws ConfigurationException { try { - xpath = XPathFactory.newInstance().newXPath(); + XPathFactory f = null; + if (XMLUnit.getXPathFactory() != null) { + f = (XPathFactory) Class.forName(XMLUnit.getXPathFactory()) + .newInstance(); + } else { + f = XPathFactory.newInstance(); + } + + xpath = f.newXPath(); } catch (Exception ex) { throw new ConfigurationException(ex); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |