Does saxon-ant support all of ant's xslt ?

  • Anonymous - 2010-05-21


    I'm trying to migrate an existing ant transformation using ant's built-in xslt
    task to the saxon-xslt task and encounter a problem with some of the
    attributes provided with the built-in task, but which doesn't seem to exist in
    the saxon-xslt task.

    The saxon-xslt ant task documentation says: "In general it follows the pattern
    of the existing xslt task, with the following extra attributes: "

    I'm using the filenameparameter and the dirnameparameter attributes of the
    built-in xslt task which allow to define the names of the xsl parameters that
    will contain the current input file and directory names. However, this doesn't
    seem to work with saxon-xslt. Is this a known limitation, or did I just
    something wrong?


  • Michael Kay

    Michael Kay - 2010-05-21

    I would advise against trying to use the saxon-xslt ant task. I tested the new
    features that were added to the task, but in the absence of a regression test
    suite, I think some of the features of the existing task stopped working, and
    I've now very little idea exactly what works and what doesn't. In the meantime
    I have found ways of controlling most aspects of Saxon processing (for example
    schema-awareness) through the properties/attributes that are already present
    on the standard task. In particular, all the configuration properties listed
    as constants in can be supplied as transformation properties
    on the Ant xslt task.

  • Jakob

    Jakob - 2010-05-21

    Thank you Michael,

    can you advise as to how one could pass the currently treated file's name (and
    possibly its path) to the xsl stylesheet? The doesn't contain
    any information on these items. Thanks, Jakob.

  • Michael Kay

    Michael Kay - 2010-05-21

    I've never used these attributes, but I would think you would do it exactly as
    described in the Ant manual,

    <xslt style="printFilename.xsl" destdir="out" basedir="in" extension=".txt"

    <factory name="net.sf.saxon.TransformerFactoryImpl"/>

    This facility shouldn't involve Saxon in any way; Ant should be using the
    standard JAXP interface to set parameter values.

  • Jakob

    Jakob - 2010-05-25

    Thanks Michael, that's what I thought (that they do actually what it says on
    the tin) but unfortunately they don't. I don't know if it's Ant or Saxon, but
    supplying the two attributes I get the following nullpointer exception, and
    without them the stylesheet compiles and is executed but doesn't have the
    desired output (which is based in part on the presence of these values).

    [saxon-xslt] AntTransform.execute() schema-aware=false version
    [saxon-xslt] Transforming into /Volumes/data/Work/keytables-conversion/working/KTD/resources
        at net.sf.saxon.ant.AntTransform.process(
        at net.sf.saxon.ant.AntTransform.execute(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
    Total time: 2 seconds
  • Michael Kay

    Michael Kay - 2010-05-25

    That crash is Ant calling Saxon in a way that Saxon doesn't expect to be
    called - which I'm afraid is typical of the problems that caused me to give up
    on the saxon-ant task. There's not enough documentation to do it without
    thorough testing, and there's no test material available to do the thorough
    testing. I suggest you abandon it and rely on the standard xslt task (or on
    exec to the command line interface) instead.

  • Jakob

    Jakob - 2010-05-25

    That's good to know. The fact I'm not using the standard xslt task (using
    Xalan I think) is that the following expression in a match template makes
    compilation fail:

    elt1[elt2[matches(text(), '^[\d]+$')]]

    The error message being:

        [xslt] Loading stylesheet K:\tests\convert.xsl
        [xslt] : Error! Error checking type of the expression
    'funcall(matches, [step("self", -1), literal-expr(\d+)])'.
        [xslt] : Fatal Error! Could not compile stylesheet
        [xslt] Failed to process null

    The stylesheet compiles fine with Saxon, but with Xalan it fails (still
    waiting for a reply from the ant users discussion list).

  • Michael Kay

    Michael Kay - 2010-05-26

    The standard Ant xslt task will of course use Apache Xalan (and therefore XSLT
    1.0) by default, but you can make it use Saxon by setting

    <factory name="net.sf.saxon.TransformerFactoryImpl"/>


Log in to post a comment.