git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267690 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -37,6 +37,10 @@ | |||
| <target name="check_for_optional_packages"> | |||
| <available property="bsf.present" classname="com.ibm.bsf.BSFManager" /> | |||
| <available property="netrexx.present" classname="netrexx.lang.Rexx" /> | |||
| <available property="xslp.present" | |||
| classname="com.kvisco.xsl.XSLProcessor" /> | |||
| <available property="xalan.present" | |||
| classname="org.apache.xalan.xslt.XSLTProcessorFactory" /> | |||
| </target> | |||
| <!-- =================================================================== --> | |||
| @@ -60,6 +64,8 @@ | |||
| optimize="on" > | |||
| <exclude name="**/Script.java" unless="bsf.present" /> | |||
| <exclude name="**/NetRexxC.java" unless="netrexx.present" /> | |||
| <exclude name="**/XslpLiaison.java" unless="xslp.present" /> | |||
| <exclude name="**/XalanLiaison.java" unless="xalan.present" /> | |||
| </javac> | |||
| <copydir src="${src.dir}" dest="${build.classes}"> | |||
| @@ -493,6 +493,7 @@ If you do not want these default excludes applied, you may disable them with the | |||
| <li><a href="#tar">Tar</a></li> | |||
| <li><a href="#taskdef">Taskdef</a></li> | |||
| <li><a href="#tstamp">Tstamp</a></li> | |||
| <li><a href="#style">Style</a></li> | |||
| <li><a href="#untar">Untar</a></li> | |||
| <li><a href="#zip">Zip</a></li> | |||
| </ul> | |||
| @@ -2287,6 +2288,67 @@ initialization target.</p> | |||
| <h3>Examples</h3> | |||
| <pre> <tstamp/></pre> | |||
| <hr> | |||
| <h2><a name="style">Style</a></h2> | |||
| <h3>Description</h3> | |||
| <p>Process a set of documents via XSLT.</p> | |||
| <p>This is useful for building views of XML based documentation, | |||
| or in generating code.</p> | |||
| <p>It is possible to refine the set of files that are being copied. This can be | |||
| done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> | |||
| attributes. With the <i>includes</i> attribute you specify the files you want to | |||
| have included by using patterns. The <i>exclude</i> attribute is used to specify | |||
| the files you want to have excluded. This is also done with patterns. And | |||
| finally with the <i>defaultexcludes</i> attribute, you can specify whether you | |||
| want to use default exclusions or not. See the section on <a | |||
| href="#directorybasedtasks">directory based tasks</a>, on how the | |||
| inclusion/exclusion of files works, and how to write patterns. The patterns are | |||
| relative to the <i>basedir</i> directory.</p> | |||
| <h3>Parameters</h3> | |||
| <table border="1" cellpadding="2" cellspacing="0"> | |||
| <tr> | |||
| <td valign="top"><b>Attribute</b></td> | |||
| <td valign="top"><b>Description</b></td> | |||
| <td align="center" valign="top"><b>Required</b></td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">basedir</td> | |||
| <td valign="top">where to find the source xml file.</td> | |||
| <td align="center" valign="top">Yes</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">destdir</td> | |||
| <td valign="top">directory where to store the results.</td> | |||
| <td align="center" valign="top">Yes</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">extention</td> | |||
| <td valign="top">desired file extension to be used for the targets. | |||
| If not specified, the default is "html".</td> | |||
| <td align="center" valign="top">No</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">style</td> | |||
| <td valign="top">name of the stylesheet to use.</td> | |||
| <td align="center" valign="top">Yes</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">processor</td> | |||
| <td valign="top">name of the XSLT processor to use. Permissable | |||
| values are "xslp" for the XSL:P processor, "xalan" for the Apache XML Xalan | |||
| processor, or the name of an arbitrary XSLTLiaison class. | |||
| Defaults to xslp or xalan (in that order), if one is found in your | |||
| class path</td> | |||
| <td align="center" valign="top">No</td> | |||
| </tr> | |||
| </table> | |||
| <h3>Examples</h3> | |||
| <blockquote> | |||
| <p><pre> | |||
| <style basedir="doc" destdir="build/doc" | |||
| extension="html" style="style/apache.xml"/> | |||
| </pre></p> | |||
| </blockquote> | |||
| <hr> | |||
| <h2><a name="untar">Untar</a></h2> | |||
| <h3>Description</h3> | |||
| <p>Untars a tarfile.</p> | |||
| @@ -0,0 +1,70 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| /** | |||
| * | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @version $Revision$ $Date$ | |||
| */ | |||
| public interface XSLTLiaison { | |||
| public void setStylesheet(String fileName) throws Exception; | |||
| public void transform(String infile, String outfile) throws Exception; | |||
| } //-- XSLTLiaison | |||
| @@ -0,0 +1,310 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| import java.io.*; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.StringTokenizer; | |||
| import java.util.Vector; | |||
| /** | |||
| * A Task to process via XSLT a set of XML documents. This is | |||
| * useful for building views of XML based documentation. | |||
| * arguments: | |||
| * <ul> | |||
| * <li>basedir | |||
| * <li>destdir | |||
| * <li>style | |||
| * <li>includes | |||
| * <li>excludes | |||
| * </ul> | |||
| * Of these arguments, the <b>sourcedir</b> and <b>destdir</b> are required. | |||
| * <p> | |||
| * This task will recursively scan the sourcedir and destdir | |||
| * looking for XML documents to process via XSLT. Any other files, | |||
| * such as images, or html files in the source directory will be | |||
| * copied into the destination directory. | |||
| * | |||
| * @author <a href="mailto:kvisco@exoffice.com">Keith Visco</a> | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @version $Revision$ $Date$ | |||
| */ | |||
| public class XSLTProcess extends MatchingTask { | |||
| private File destDir = null; | |||
| private File baseDir = null; | |||
| private File xslFile = null; | |||
| private String targetExtension = "html"; | |||
| private XSLTLiaison liaison; | |||
| /** | |||
| * Creates a new XSLTProcess Task. | |||
| **/ | |||
| public XSLTProcess() { | |||
| } //-- XSLTProcess | |||
| /** | |||
| * Executes the task. | |||
| */ | |||
| public void execute() throws BuildException { | |||
| DirectoryScanner scanner; | |||
| String[] list; | |||
| String[] dirs; | |||
| if (baseDir == null) | |||
| baseDir = project.resolveFile("."); | |||
| //-- make sure Source directory exists... | |||
| if (destDir == null ) { | |||
| String msg = "destdir attributes must be set!"; | |||
| throw new BuildException(msg); | |||
| } | |||
| scanner = getDirectoryScanner(baseDir); | |||
| project.log("Transforming into "+destDir,project.MSG_INFO); | |||
| try { | |||
| // Create a new XSL processor with the specified stylesheet | |||
| if (xslFile != null) { | |||
| project.log("Loading stylesheet " + xslFile, project.MSG_INFO); | |||
| liaison.setStylesheet( new File(baseDir,xslFile.toString()).toString() ); | |||
| } | |||
| } catch (Exception ex) { | |||
| project.log("Failed to read stylesheet " + xslFile,project.MSG_INFO); | |||
| throw new BuildException(ex); | |||
| } | |||
| // Process all the files marked for styling | |||
| list = scanner.getIncludedFiles(); | |||
| for (int i = 0;i < list.length; ++i) { | |||
| process(baseDir,list[i],destDir); | |||
| } | |||
| // Process all the directoried marked for styling | |||
| dirs = scanner.getIncludedDirectories(); | |||
| for (int j = 0;j < dirs.length;++j){ | |||
| list=new File(baseDir,dirs[j]).list(); | |||
| for (int i = 0;i < list.length;++i) | |||
| process(baseDir,list[i],destDir); | |||
| } | |||
| } //-- execute | |||
| /** | |||
| * Set the base directory. | |||
| **/ | |||
| public void setBasedir(String dirName) { | |||
| baseDir = project.resolveFile(dirName); | |||
| } //-- setSourceDir | |||
| /** | |||
| * Set the destination directory into which the XSL result | |||
| * files should be copied to | |||
| * @param dirName the name of the destination directory | |||
| **/ | |||
| public void setDestdir(String dirName) { | |||
| destDir = project.resolveFile(dirName); | |||
| } //-- setDestDir | |||
| /** | |||
| * Set the desired file extension to be used for the target | |||
| * @param name the extension to use | |||
| **/ | |||
| public void setExtension(String name) { | |||
| targetExtension = name; | |||
| } //-- setDestDir | |||
| /** | |||
| * Sets the file to use for styling relative to the base directory. | |||
| */ | |||
| public void setStyle(String xslFile) { | |||
| this.xslFile = new File(xslFile); | |||
| } | |||
| /** | |||
| * Sets the file to use for styling relative to the base directory. | |||
| */ | |||
| public void setProcessor(String processor) throws Exception { | |||
| if (processor.equals("xslp")) { | |||
| liaison = (XSLTLiaison) Class.forName("org.apache.tools.ant.taskdefs.optional.XslpLiaison").newInstance(); | |||
| } if (processor.equals("xalan")) { | |||
| liaison = (XSLTLiaison) Class.forName("org.apache.tools.ant.taskdefs.optional.XalanLiaison").newInstance(); | |||
| } else { | |||
| liaison = (XSLTLiaison) Class.forName(processor).newInstance(); | |||
| } | |||
| } | |||
| /* | |||
| private void process(File sourceDir, File destDir) | |||
| throws BuildException | |||
| { | |||
| // if processor wasn't specified, default it to xslp or xalan, | |||
| // depending on which is in the classpath | |||
| if (liaison == null) | |||
| try { | |||
| setProcessor("xslp"); | |||
| } catch (Exception e) { | |||
| try { | |||
| setProcessor("xalan"); | |||
| } catch (Exception e) { | |||
| throw new BuildException(e); | |||
| } | |||
| } | |||
| } | |||
| if (!sourceDir.isDirectory()) { | |||
| throw new BuildException(sourceDir.getName() + | |||
| " is not a directory!"); | |||
| } | |||
| else if (!destDir.isDirectory()) { | |||
| throw new BuildException(destDir.getName() + | |||
| " is not a directory!"); | |||
| } | |||
| String[] list = sourceDir.list(new DesirableFilter()); | |||
| if (list == null) { | |||
| return; //-- nothing to do | |||
| } | |||
| for (int i = 0; i < list.length; i++) { | |||
| String filename = list[i]; | |||
| File inFile = new File(sourceDir, filename); | |||
| //-- if inFile is a directory, recursively process it | |||
| if (inFile.isDirectory()) { | |||
| if (!excluded(filename)) { | |||
| new File(destDir, filename).mkdir(); | |||
| process(inFile, new File(destDir, filename)); | |||
| } | |||
| } | |||
| //-- process XML files | |||
| else if (hasXMLFileExtension(filename) && ! excluded(filename)) { | |||
| //-- replace extension with the target extension | |||
| int idx = filename.lastIndexOf('.'); | |||
| File outFile = new File(destDir, | |||
| filename.substring(0,idx) + targetExt); | |||
| if ((inFile.lastModified() > outFile.lastModified()) || | |||
| (xslFile != null && xslFile.lastModified() > outFile.lastModified())) | |||
| { | |||
| processXML(inFile, outFile); | |||
| } | |||
| } | |||
| else { | |||
| File outFile = new File(destDir, filename); | |||
| if (inFile.lastModified() > outFile.lastModified()) { | |||
| try { | |||
| copyFile(inFile, outFile); | |||
| } | |||
| catch(java.io.IOException ex) { | |||
| String err = "error copying file: "; | |||
| err += inFile.getAbsolutePath(); | |||
| err += "; " + ex.getMessage(); | |||
| throw new BuildException(err, ex); | |||
| } | |||
| //filecopyList.put(srcFile.getAbsolutePath(), | |||
| //destFile.getAbsolutePath()); | |||
| } | |||
| } | |||
| } //-- </for> | |||
| } //-- process(File, File) | |||
| */ | |||
| /** | |||
| * Processes the given input XML file and stores the result | |||
| * in the given resultFile. | |||
| **/ | |||
| private void process(File baseDir,String xmlFile,File destDir) | |||
| throws BuildException | |||
| { | |||
| String fileExt=".html"; | |||
| File outFile=null; | |||
| File inFile=null; | |||
| try { | |||
| inFile = new File(baseDir,xmlFile); | |||
| outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt); | |||
| if (inFile.lastModified() > outFile.lastModified()) { | |||
| //-- command line status | |||
| project.log("Processing " + xmlFile + " to " + outFile,project.MSG_VERBOSE); | |||
| liaison.transform(inFile.toString(), outFile.toString()); | |||
| } | |||
| } | |||
| catch (Exception ex) { | |||
| // If failed to process document, must delete target document, | |||
| // or it will not attempt to process it the second time | |||
| project.log("Failed to process " + inFile,project.MSG_INFO); | |||
| outFile.delete(); | |||
| throw new BuildException(ex); | |||
| } | |||
| } //-- processXML | |||
| } //-- XSLTProcess | |||
| @@ -31,6 +31,7 @@ fixcrlf=org.apache.tools.ant.taskdefs.FixCRLF | |||
| rename=org.apache.tools.ant.taskdefs.Rename | |||
| patch=org.apache.tools.ant.taskdefs.Patch | |||
| compileTask=org.apache.tools.ant.taskdefs.CompileTask | |||
| style=org.apache.tools.ant.taskdefs.XSLTProcess | |||
| # optional tasks | |||
| script=org.apache.tools.ant.taskdefs.optional.Script | |||
| @@ -0,0 +1,84 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| 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; | |||
| /** | |||
| * | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @version $Revision$ $Date$ | |||
| */ | |||
| public class XalanLiaison implements XSLTLiaison { | |||
| XSLTProcessor processor; | |||
| XSLTInputSource xslSheet; | |||
| public void setStylesheet(String fileName) throws Exception { | |||
| xslSheet = new XSLTInputSource (fileName); | |||
| }; | |||
| public void transform(String infile, String outfile) throws Exception { | |||
| if (processor == null) processor = XSLTProcessorFactory.getProcessor(); | |||
| processor.process(new XSLTInputSource(infile), xslSheet, | |||
| new XSLTResultTarget(outfile)); | |||
| } | |||
| } //-- XalanLiaison | |||
| @@ -0,0 +1,85 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import java.io.FileWriter; | |||
| import org.apache.tools.ant.taskdefs.XSLTLiaison; | |||
| import com.kvisco.xsl.XSLProcessor; | |||
| import com.kvisco.xsl.XSLReader; | |||
| import com.kvisco.xsl.XSLStylesheet; | |||
| /** | |||
| * | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @version $Revision$ $Date$ | |||
| */ | |||
| public class XslpLiaison implements XSLTLiaison { | |||
| XSLProcessor processor; | |||
| XSLStylesheet xslSheet; | |||
| public void setStylesheet(String fileName) throws Exception { | |||
| XSLReader xslReader = new XSLReader(); | |||
| xslSheet = xslReader.read( fileName ); | |||
| }; | |||
| public void transform(String infile, String outfile) throws Exception { | |||
| if (processor == null) processor = new XSLProcessor(); | |||
| processor.process(infile, xslSheet, new FileWriter(outfile)); | |||
| } | |||
| } //-- XSLPLiaison | |||