From: <bo...@us...> - 2007-03-28 04:06:23
|
Revision: 158 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=158&view=rev Author: bodewig Date: 2007-03-27 21:06:22 -0700 (Tue, 27 Mar 2007) Log Message: ----------- Allow custom URI resolvers Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java 2007-03-27 04:31:56 UTC (rev 157) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java 2007-03-28 04:06:22 UTC (rev 158) @@ -191,10 +191,13 @@ throws ConfigurationException { try { TransformerFactory factory = XMLUnit.getTransformerFactory(); - if (stylesheetSource == null) { - return factory.newTransformer(); + Transformer t = stylesheetSource == null + ? factory.newTransformer() + : factory.newTransformer(stylesheetSource); + if (XMLUnit.getURIResolver() != null) { + t.setURIResolver(XMLUnit.getURIResolver()); } - return factory.newTransformer(stylesheetSource); + return t; } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(ex); } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2007-03-27 04:31:56 UTC (rev 157) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2007-03-28 04:06:22 UTC (rev 158) @@ -43,6 +43,7 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.TransformerFactory; +import javax.xml.transform.URIResolver; import java.io.IOException; import java.io.Reader; @@ -62,6 +63,7 @@ private static DocumentBuilderFactory testBuilderFactory; private static TransformerFactory transformerFactory; private static boolean ignoreWhitespace = false; + private static URIResolver uriResolver = null; private static EntityResolver testEntityResolver = null; private static EntityResolver controlEntityResolver = null; private static NamespaceContext namespaceContext = null; @@ -443,8 +445,21 @@ return transformerFactory; } + /** + * Sets the URIResolver to use during transformations. + */ + public static void setURIResolver(URIResolver resolver) { + uriResolver = resolver; + } /** + * Gets the URIResolver used during Transformations. + */ + public static URIResolver getURIResolver() { + return uriResolver; + } + + /** * Override the SAX parser to use in tests. * Currently only used by {@link Validator Validator class} * @param className This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |