Browse Source

Make <style> support Exolab's new Adaptx processor.

Submitted by:	Arnaud Blandin <blandin@intalio.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269832 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
65c82879ee
6 changed files with 212 additions and 14 deletions
  1. +15
    -0
      build.xml
  2. +8
    -5
      docs/manual/CoreTasks/style.html
  3. +6
    -4
      docs/manual/install.html
  4. +15
    -5
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  5. +96
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/AdaptxLiaison.java
  6. +72
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/AdaptxLiaisonTest.java

+ 15
- 0
build.xml View File

@@ -166,6 +166,13 @@
<available property="servlet.present"
classname="javax.servlet.Servlet"
classpathref="classpath"/>

<available property="adaptx.present"
classname="org.exolab.adaptx.xslt.XSLTProcessor"
classpathref="classpath" />
<available property="xerces.present"
classname="org.apache.xerces.parsers.SAXParser"
classpathref="classpath" />
<condition property="javamail.complete">
<and>
@@ -236,6 +243,7 @@
<exclude name="${optional.package}/NetRexxC.java" unless="netrexx.present" />
<exclude name="${optional.package}/XslpLiaison.java" unless="xslp.present" />
<exclude name="${optional.package}/XalanLiaison.java" unless="xalan.present" />
<exclude name="${optional.package}/AdaptxLiaison.java" unless="adaptx.present" />
<exclude name="${optional.package}/ejb/Ejbc*.java" unless="ejb.ejbc.present" />
<exclude name="${optional.package}/ejb/DDCreator*.java" unless="ejb.DDCreator.present" />
<exclude name="${optional.package}/ejb/WLRun.java" unless="ejb.wls.present" />
@@ -663,6 +671,8 @@
unless="xslp.present"/>
<exclude name="org/apache/tools/ant/taskdefs/optional/XalanLiaisonTest.java"
unless="xalan.present"/>
<exclude name="org/apache/tools/ant/taskdefs/optional/AdaptxLiaisonTest.java"
unless="adaptx.present"/>
</javac>
</target>

@@ -744,6 +754,11 @@
<exclude name="org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java" />
<exclude name="org/apache/tools/ant/taskdefs/optional/XslpLiaisonTest.java" unless="xslp.present"/>
<exclude name="org/apache/tools/ant/taskdefs/optional/XalanLiaisonTest.java" unless="xalan.present"/>

<exclude name="org/apache/tools/ant/taskdefs/optional/AdaptxLiaisonTest.java"
unless="adaptx.present"/>
<exclude name="org/apache/tools/ant/taskdefs/optional/AdaptxLiaisonTest.java"
unless="xerces.present"/>
<!-- ehm, this is not really a TraX test but rather a xalan2 test..-->
<exclude name="org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java" unless="xalan2.present"/>


+ 8
- 5
docs/manual/CoreTasks/style.html View File

@@ -87,11 +87,14 @@ inclusion/exclusion of files works, and how to write patterns.</p>
<td valign="top">name of the XSLT processor to use. Permissible values are
&quot;trax&quot; for a TraX compliant processor, &quot;xslp&quot; for the
XSL:P processor, &quot;xalan&quot; for the Apache XML Xalan (version 1)
processor, or the name of an arbitrary XSLTLiaison class. Defaults to trax,
followed by xslp then xalan (in that order). The first one found in your
class path is the one that is used.
<em><strong>DEPRECATED</strong> - XSL:P is deprecated and will be removed
in the next version. Use trax or xalan instead.</em>.
processor, &quot;adaptx&quot; for the Exolab Adaptx processor
or the name of an arbitrary XSLTLiaison class. Defaults to trax,
followed by xalan, then adaptx and then xslp (in that
order). The first one found in your class path is the one that
is used.
<em><strong>DEPRECATED</strong> - XSL:P and Adaptx are
deprecated and will be removed in the next version. Use trax or
xalan instead.</em>.
</td>
<td align="center" valign="top">No</td>
</tr>


+ 6
- 4
docs/manual/install.html View File

@@ -249,11 +249,13 @@ Installing Ant / Optional Tasks</a> section above.</p>
<td><b>Available At</b></td>
</tr>
<tr>
<td>An XSL transformer like Xalan or XSL:P</td>
<td>An XSL transformer like Xalan, Adaptx or XSL:P</td>
<td>style task</td>
<td><a href="http://xml.apache.org/xalan-j/index.html"
target="_top">http://xml.apache.org/xalan-j/index.html</a> or <a
href="http://www.clc-marketing.com/xslp/"
target="_top">http://xml.apache.org/xalan-j/index.html</a>,
CVS module adaptx from :pserver:anoncvs@virtuals.intalio.com:/cvs/adaptx
with password anoncvs
or <a href="http://www.clc-marketing.com/xslp/"
target="_top">http://www.clc-marketing.com/xslp/</a></td>
</tr>
<tr>
@@ -262,7 +264,7 @@ Installing Ant / Optional Tasks</a> section above.</p>
<td><a href="http://jakarta.apache.org/regexp/" target="_top">jakarta.apache.org/regexp/</a></td>
</tr>
<tr>
<td>jakarta-oro-2.0.1.jar</td>
<td>jakarta-oro-2.0.4.jar</td>
<td>regexp type with mappers and the perforce tasks</td>
<td><a href="http://jakarta.apache.org/oro/" target="_top">jakarta.apache.org/oro/</a></td>
</tr>


+ 15
- 5
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -278,6 +278,11 @@ public class XSLTProcess extends MatchingTask {
final Class clazz =
loadClass("org.apache.tools.ant.taskdefs.optional.XalanLiaison");
liaison = (XSLTLiaison)clazz.newInstance();
} else if (proc.equals("adaptx")) {
log("DEPRECATED - adaptx processor is deprecated. Use trax or xalan instead.");
final Class clazz =
loadClass("org.apache.tools.ant.taskdefs.optional.AdaptxLiaison");
liaison = (XSLTLiaison) clazz.newInstance();
} else {
liaison = (XSLTLiaison) loadClass(proc).newInstance();
}
@@ -402,14 +407,19 @@ public class XSLTProcess extends MatchingTask {
resolveProcessor("trax");
} catch (Throwable e1) {
try {
resolveProcessor("xslp");
resolveProcessor("xalan");
} catch (Throwable e2) {
try {
resolveProcessor("xalan");
resolveProcessor("adaptx");
} catch (Throwable e3) {
e3.printStackTrace();
e2.printStackTrace();
throw new BuildException(e1);
try {
resolveProcessor("xslp");
} catch (Throwable e4) {
e4.printStackTrace();
e3.printStackTrace();
e2.printStackTrace();
throw new BuildException(e1);
}
}
}
}


+ 96
- 0
src/main/org/apache/tools/ant/taskdefs/optional/AdaptxLiaison.java View File

@@ -0,0 +1,96 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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", "Ant", 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.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;

import org.apache.tools.ant.taskdefs.XSLTLiaison;

import org.exolab.adaptx.xslt.XSLTProcessor;
import org.exolab.adaptx.xslt.XSLTReader;
import org.exolab.adaptx.xslt.XSLTStylesheet;

/**
*
* @author <a href="mailto:blandin@intalio.com">Arnaud Blandin</a>
* @version $Revision$ $Date$
*/
public class AdaptxLiaison implements XSLTLiaison {

protected XSLTProcessor processor;
protected XSLTStylesheet xslSheet;

public AdaptxLiaison () {
processor = new XSLTProcessor();
}

public void setStylesheet(File fileName) throws Exception {
XSLTReader xslReader = new XSLTReader();
xslSheet = xslReader.read( fileName.getAbsolutePath() );
};

public void transform(File infile, File outfile) throws Exception {
FileOutputStream fos = new FileOutputStream(outfile);
OutputStreamWriter out = new OutputStreamWriter(fos,"UTF8");
processor.process(infile.getAbsolutePath(), xslSheet, out);
}

public void addParam(String name, String expression){
processor.setProperty(name, expression);
}

} //-- AdaptxLiaison

+ 72
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/AdaptxLiaisonTest.java View File

@@ -0,0 +1,72 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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", "Jakarta-Regexp", 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;

/**
* Adaptx Liaison testcase
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class AdaptxLiaisonTest extends AbstractXSLTLiaisonTest {
public AdaptxLiaisonTest(String name){
super(name);
}

protected XSLTLiaison createLiaison() throws Exception {
return new AdaptxLiaison();
}
}

Loading…
Cancel
Save