ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craeg K Strong <cstr...@arielpartners.com>
Subject Re: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs
Date Mon, 27 May 2002 19:45:21 GMT
  XSLTProcess.java
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hello Stefan:

I agree with your reasoning about not making XSLTProcess _depend_ on the TRAX
API, since it can also use non-TRAX XSLT processors.  Removing the dependency
via reflection is the right thing to do IMO.

However, I would propose an alternate solution for the tests.  I happen
to prefer the Saxon XSLT processor to Xalan.  Of course, I still fully support
bundling Xalan with Ant.   I often find it extremely useful to test my XSLT code
with _both_ processors, comparing the results I get with each one.

The way you have coded it, I must change build.xml to switch.  While its
not difficult, it is a little inconvenient.

What about testing for an _implementation_ of TRAX, and excluding the XSLT tests
iff the TRAX _implementation_ is not present?

That is, instead of:

    <exclude name="${optional.package}/XsltTest.java"
         unless="xalan2.present"/>

Have something like

     <exclude name="${optional.package}/XsltTest.java"
        unless= "trax.impl.present"/>

Where "trax.impl.present" is defined something like the following:

      <condition property="trax.impl.present">
        <or>
          <and>
            <isset property="javax.xml.transform.TransformerFactory"/>
            <available classname="${javax.xml.transform.TransformerFactory}"
                       classpathref="classpath" />
          </and>
          <available
resource="META-INF/services/javax.xml.transform.TransformerFactory"/>
        </or>
      </condition>

The above is not perfect (See JAXP 1.1 specification, page 19/section 3.3 "XSLT
Pluggability") but it works for the normal case where you simply either:

a) drop in either the saxon.jar or xalan.jar or
b) keep them both in the classpath and define the TransformerFactory property
     to point to the one you want

Using this kind of technique, the test will execute if saxon _OR_ xalan is present.

--Craeg

bodewig@apache.org wrote:
 > bodewig     02/05/27 02:13:36
 >
 >   Modified:    .        Tag: ANT_15_BRANCH build.xml
 >                src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
 >                         XSLTProcess.java
 >   Log:
 >   Remove direct TraX compile-time dependency from <style>.
 >
 >   There still is an indirect dependency via XMLCatalog, of course.
 >
 >   Revision  Changes    Path
 >   No                   revision
 >
 >
 >   No                   revision
 >
 >
 >   1.304.2.10 +1 -1      jakarta-ant/build.xml
 >
 >   Index: build.xml
 >   ===================================================================
 >   RCS file: /home/cvs/jakarta-ant/build.xml,v
 >   retrieving revision 1.304.2.9
 >   retrieving revision 1.304.2.10
 >   diff -u -r1.304.2.9 -r1.304.2.10
 >   --- build.xml	27 May 2002 08:47:25 -0000	1.304.2.9
 >   +++ build.xml	27 May 2002 09:13:36 -0000	1.304.2.10
 >   @@ -1275,7 +1275,7 @@
 >              <!-- these tests need to be localised before being ran???? -->
 >              <exclude name="${optional.package}/PvcsTest.java" />
 >
 >   -          <!-- ehm, these are not really a TraX test but rather a xalan2 
test..-->
 >   +          <!-- ehm, these are not really TraX tests but rather xalan2 
tests..-->
 >              <exclude name="${optional.package}/TraXLiaisonTest.java"
 >                       unless="xalan2.present"/>
 >              <exclude name="${optional.package}/XsltTest.java"
 >
 >
 >
 >   No                   revision
 >
 >
 >   No                   revision
 >
 >
 >   1.43.2.2  +11 -6 
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
 >
 >   Index: XSLTProcess.java
 >   ===================================================================
 >   RCS file: 
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java,v
 >   retrieving revision 1.43.2.1
 >   retrieving revision 1.43.2.2
 >   diff -u -r1.43.2.1 -r1.43.2.2
 >   --- XSLTProcess.java	24 May 2002 15:47:57 -0000	1.43.2.1
 >   +++ XSLTProcess.java	27 May 2002 09:13:36 -0000	1.43.2.2
 >   @@ -67,13 +67,12 @@
 >    import org.apache.tools.ant.util.FileUtils;
 >    import org.apache.tools.ant.types.XMLCatalog;
 >    import org.xml.sax.EntityResolver;
 >   -import javax.xml.transform.URIResolver;
 >
 >    /**
 >     * A Task to process via XSLT a set of XML documents. This is
 >     * useful for building views of XML based documentation.
 >     *
 >   - * @version $Revision: 1.43.2.1 $
 >   + * @version $Revision: 1.43.2.2 $
 >     *
 >     * @author <a href="mailto:kvisco@exoffice.com">Keith Visco</a>
 >     * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
 >   @@ -662,6 +661,12 @@
 >                    Param p = (Param) e.nextElement();
 >                    liaison.addParam(p.getName(), p.getExpression());
 >                }
 >   +        } catch (Exception ex) {
 >   +            log("Failed to read stylesheet " + stylesheet, Project.MSG_INFO);
 >   +            throw new BuildException(ex);
 >   +        }
 >   +
 >   +        try {
 >                // if liaison is a TraxLiason, use XMLCatalog as the entity
 >                // resolver and URI resolver
 >                if (liaison.getClass().getName().equals(TRAX_LIAISON_CLASS) &&
 >   @@ -675,12 +680,12 @@
 >
 >                    resolver = liaison.getClass()
 >                        .getDeclaredMethod("setURIResolver",
 >   -                                       new Class[] {URIResolver.class});
 >   +                                       new Class[] 
{loadClass("javax.xml.transform.URIResolver")});
 >                    resolver.invoke(liaison, new Object[] {xmlCatalog});
 >                }
 >   -        } catch (Exception ex) {
 >   -            log("Failed to read stylesheet " + stylesheet, Project.MSG_INFO);
 >   -            throw new BuildException(ex);
 >   +        } catch (Exception e) {
 >   +            throw new BuildException("Failed to configure XMLCatalog for "
 >   +                                     + "TraxLiaison", e);
 >            }
 >        }
 >
 >
 >
 >
 >
 > --
 > To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
 > For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
 >


-- 
Craeg K Strong, General Partner
Ariel Partners LLC
http://www.arielpartners.com
voice 781-647-2425
fax   781-647-9690

NOTICE: This message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any review,
retransmission, dissemination or other use of, or taking of any action
in reliance upon, this information by persons or entities other than
the intended recipient is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies -- including electronic copies -- of the original message.


-- 
Craeg K Strong, General Partner
Ariel Partners LLC
http://www.arielpartners.com
voice 781-647-2425
fax   781-647-9690

NOTICE: This message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any review,
retransmission, dissemination or other use of, or taking of any action
in reliance upon, this information by persons or entities other than
the intended recipient is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies -- including electronic copies -- of the original message.


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message