It upgrades Ant Optional tasks to be Xalan 2 compliant and not use any of Xalan 1's API.
? ant.diff ? lib/optional/xalan-2.2.0-dev.jar Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-ant/build.xml,v retrieving revision 1.171 diff -u -r1.171 build.xml --- build.xml 2001/08/06 10:24:02 1.171 +++ build.xml 2001/08/06 16:34:53 @@ -99,7 +100,7 @@ classname="com.kvisco.xsl.XSLProcessor" classpathref="classpath" /> <available property="xalan.present" - classname="org.apache.xalan.xslt.XSLTProcessorFactory" + classname="javax.xml.transform.TransformerFactory" classpathref="classpath" /> <available property="ejb.ejbc.present" classname="weblogic.ejbc" Index: src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java,v retrieving revision 1.5 diff -u -r1.5 XalanLiaison.java --- src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java 2001/01/03 14:18:35 1.5 +++ src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java 2001/08/06 +16:35:01 @@ -56,10 +56,12 @@ import org.apache.tools.ant.taskdefs.XSLTLiaison; -import org.apache.xalan.xslt.XSLTProcessorFactory; -import org.apache.xalan.xslt.XSLTProcessor; -import org.apache.xalan.xslt.XSLTInputSource; -import org.apache.xalan.xslt.XSLTResultTarget; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.Source; +import javax.xml.transform.Result; +import javax.xml.transform.stream.StreamSource; +import javax.xml.transform.stream.StreamResult; /** * @@ -70,20 +72,22 @@ protected final static String FILEURL = "file:"; - XSLTProcessor processor; - XSLTInputSource xslSheet; + TransformerFactory factory; + Transformer processor; + Source xslSheet; public XalanLiaison() throws Exception { - processor = XSLTProcessorFactory.getProcessor(); + this.factory = TransformerFactory.newInstance(); } public void setStylesheet(String fileName) throws Exception { - xslSheet = new XSLTInputSource (normalize(fileName)); + xslSheet = new StreamSource (normalize(fileName)); + processor = factory.newTransformer(xslSheet); }; public void transform(String infile, String outfile) throws Exception { - processor.process(new XSLTInputSource(normalize(infile)), xslSheet, - new XSLTResultTarget(outfile)); + processor.transform(new StreamSource(normalize(infile)), + new StreamResult(outfile)); } protected String normalize(String fileName) { @@ -94,6 +98,6 @@ } public void addParam(String name, String value){ - processor.setStylesheetParam(name, value); + processor.setParameter(name, value); } } //-- XalanLiaison Index: src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java,v retrieving revision 1.4 diff -u -r1.4 AggregateTransformer.java --- src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java 2001/08/02 22:47:16 1.4 +++ src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java + 2001/08/06 16:35:02 @@ -68,10 +68,13 @@ import java.util.Enumeration; import java.util.Hashtable; -import org.apache.xalan.xslt.XSLTProcessorFactory; -import org.apache.xalan.xslt.XSLTProcessor; -import org.apache.xalan.xslt.XSLTInputSource; -import org.apache.xalan.xslt.XSLTResultTarget; +import javax.xml.transform.Result; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.Transformer; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; @@ -125,20 +128,20 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Bailliez</a> * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas Delahaye</a> */ -public class AggregateTransformer { - +public class AggregateTransformer { + public final static String ALLPACKAGES = "all-packages"; - + public final static String ALLCLASSES = "all-classes"; - + public final static String OVERVIEW_PACKAGES = "overview-packages"; - + public final static String CLASS_DETAILS = "class-details"; - + public final static String CLASSES_LIST = "classes-list"; - + public final static String PACKAGE_SUMMARY = "package-summary"; - + public final static String OVERVIEW_SUMMARY = "overview-summary"; public final static String FRAMES = "frames"; @@ -224,7 +227,7 @@ final long t0 = System.currentTimeMillis(); try { Element root = document.getDocumentElement(); - + if (NOFRAMES.equals(format)) { //createCascadingStyleSheet(); createSinglePageSummary(root); @@ -303,7 +306,7 @@ OutputStream out = new FileOutputStream( new File(toDir, "index.html") ); copy(in, out); } - + /** * Create the list of all packages. * @param root root of the xml document. @@ -365,10 +368,10 @@ * @param root should be 'testsuite' node. */ protected void createTestSuiteDetails(Element testsuite) throws SAXException { - - String packageName = testsuite.getAttribute(XMLConstants.ATTR_PACKAGE); + + String packageName = testsuite.getAttribute(XMLConstants.ATTR_PACKAGE); String pkgPath = packageToPath(packageName); - + // get the class name String name = testsuite.getAttribute(XMLConstants.ATTR_NAME); @@ -449,8 +452,9 @@ */ protected void transform(Node root, String xslname, String htmlname) throws SAXException { try{ - XSLTInputSource xsl_source = getXSLStreamSource(xslname); - XSLTProcessor processor = XSLTProcessorFactory.getProcessor(); + Source xsl_source = getXSLStreamSource(xslname); + TransformerFactory factory = TransformerFactory.newInstance(); + Transformer processor = factory.newTransformer(xsl_source); File htmlfile = new File(toDir, htmlname); // create the directory if it does not exist File dir = new File(htmlfile.getParent()); // getParentFile is in JDK1.2+ @@ -458,8 +462,8 @@ dir.mkdirs(); } task.log("Applying '" + xslname + "'. Generating '" + htmlfile + "'", Project.MSG_VERBOSE); - processor.process( new XSLTInputSource(root), xsl_source, new XSLTResultTarget(htmlfile.getAbsolutePath()) ); - } catch (IOException e){ + processor.transform( new DOMSource(root), new +StreamResult(htmlfile.getAbsolutePath()) ); + } catch (Exception e){ task.log(e.getMessage(), Project.MSG_ERR); e.printStackTrace(); //@todo bad, change this throw new SAXException(e.getMessage()); @@ -472,7 +476,7 @@ * them, otherwise we will get the one supplied by the client in a given * directory. It must have the same name. */ - protected XSLTInputSource getXSLStreamSource(String name) throws IOException { + protected Source getXSLStreamSource(String name) throws IOException { InputStream in; String systemId; //we need this because there are references in xsls if (styleDir == null){ @@ -483,7 +487,7 @@ in= new FileInputStream(f); systemId = "file:///" + f.getAbsolutePath(); } - XSLTInputSource ss = new XSLTInputSource(in); + Source ss = new StreamSource(in); ss.setSystemId(systemId); return ss; }