Configuration when running Ant It is possible to run XSLT transformations from Ant using the xslt
task, selecting Saxon as the XSLT processor by setting the
factory
child element to the Saxon implementation class of javax.xml.transform.TransformerFactory
; that is one of net.sf.saxon.TransformerFactoryImpl , com.saxonica.config.ProfessionalTransformerFactory , or com.saxonica.config.EnterpriseTransformerFactory depending on the Saxon edition in
use.
Additional configuration options can be specified using the attribute
child of the factory
element, for example the
following task was used as part of the pipeline for publishing this documentation:
<xslt in="${userdoc.dir}/src/function-data.xml"
style="${userdoc.dir}/style/preprocess-functions.xsl"
out="${userdoc.dir}/src/functions.xml"
classpath="e:/saxon/eej/saxon-ee-10.0.jar;e:/saxon/eej/saxon-licenses">
<factory name="com.saxonica.config.EnterpriseTransformerFactory">
<attribute name="http://saxon.sf.net/feature/xsltSchemaAware" value="true"/>
<attribute name="http://saxon.sf.net/feature/schema-validation-mode" value="strict"/>
<attribute name="http://saxon.sf.net/feature/xsd-version" value="1.1"/>
</factory>
</xslt> Many of the options available as configuration parameters (for example Feature.XSLT_INITIAL_TEMPLATE ) were provided explicitly with Ant in mind. The provision of these parameters makes the customized version
of the Ant XSLT task provided with some earlier Saxon versions redundant, and the customized task is no longer supported.
One configuration property that is particularly useful when running Ant is
http://saxon.sf.net/feature/ignoreSAXSourceParser
. Normally, Saxon attempts
to set its own EntityResolver
on the XML parser used for parsing source documents,
because this allows commonly used DTDs and external entities to be fetched from Saxon's internal
copies rather than from the web. However, when the application invoking Saxon supplies its own
pre-configured XML parser, Saxon normally respects this and does not change the settings supplied.
Ant, when it invokes Saxon, supplies an XML parser, so by default Saxon will not set its own
EntityResolver
. Setting the ignoreSAXSourceParser
configuration option
in an attribute
child of the factory
element overrides this. This can
give dramatic performance improvements when using Ant to transform documents that contain references
to these common W3C DTDs and entity files.