Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs.optional

public Class TraXLiaison

extends Object
implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.taskdefs.XSLTLoggerAware, javax.xml.transform.ErrorListener, org.apache.tools.ant.taskdefs.XSLTLiaison4, org.apache.tools.ant.taskdefs.XSLTLiaison3, org.apache.tools.ant.taskdefs.XSLTLiaison2, org.apache.tools.ant.taskdefs.XSLTLiaison
Imports
java.io.BufferedInputStream, .BufferedOutputStream, .File, .IOException, .InputStream, .OutputStream, java.lang.reflect.Field, java.net.URL, java.nio.file.Files, java.util.ArrayList, .HashMap, .Hashtable, .List, .Map, .Vector, javax.xml.parsers.ParserConfigurationException, .SAXParserFactory, javax.xml.transform.ErrorListener, .Source, .SourceLocator, .Templates, .Transformer, .TransformerConfigurationException, .TransformerException, .TransformerFactory, .URIResolver, javax.xml.transform.sax.SAXSource, javax.xml.transform.stream.StreamResult, .StreamSource, org.apache.tools.ant.BuildException, .Project, org.apache.tools.ant.taskdefs.XSLTLiaison4, .XSLTLogger, .XSLTLoggerAware, .XSLTProcess, org.apache.tools.ant.types.Resource, .XMLCatalog, org.apache.tools.ant.types.resources.FileProvider, .FileResource, .URLProvider, org.apache.tools.ant.util.FileUtils, .JAXPUtils, .JavaEnvUtils, .StreamUtils, org.xml.sax.EntityResolver, .InputSource, .SAXException, .XMLReader

Concrete liaison for XSLT processor implementing TraX. (ie JAXP 1.1)
Since
Ant 1.3

Field Summary

Modifier and TypeField and Description
private final List<Object[]>
attributes

factory attributes

private EntityResolver
entityResolver

possible resolver for publicIds

private String
factoryName

the name of the factory implementation class to use or null for default JAXP lookup.

private final Map<String, Boolean>
features

factory features

private static final FileUtils
FILE_UTILS

Helper for transforming filenames to URIs.

private XSLTLogger
private final Vector<String[]>
outputProperties

transformer output properties

private final Hashtable<String, Object>
params

stylesheet parameters

private Project
project

The current Project

private Resource
stylesheet

stylesheet to use for transformation

private boolean
suppressWarnings

whether to suppress warnings

private Templates
templates

The In memory version of the stylesheet

private long
templatesModTime

The modification time of the stylesheet from which the templates are read

private TransformerFactory
tfactory

The trax TransformerFactory

private XSLTProcess.TraceConfiguration
traceConfiguration

optional trace configuration.

private Transformer
transformer

transformer to use for processing files

private URIResolver
uriResolver

possible resolver for URIs

Constructor Summary

AccessConstructor and Description
public
TraXLiaison()

Constructor for TraXLiaison.

Method Summary

Modifier and TypeMethod and Description
public void
addParam(final String
the name of the parameter
name
,
final String
the value of the parameter
value
)

Implements org.apache.tools.ant.taskdefs.XSLTLiaison.addParam.

Add a parameter.
public void
addParam(final String
the name of the parameter
name
,
final Object
the value of the parameter
value
)

Implements org.apache.tools.ant.taskdefs.XSLTLiaison4.addParam.

Add a parameter.
private void
public void
configure(final XSLTProcess
the XSLTProcess task instance from which this liaison is to be configured.
xsltTask
)

Implements org.apache.tools.ant.taskdefs.XSLTLiaison2.configure.

Specific configuration for the TRaX liaison.
private void
createTransformer()

Create a new transformer based on the liaison settings

public void
error(final TransformerException
the exception to log.
e
)

Implements javax.xml.transform.ErrorListener.error.

Log an error.
public void
fatalError(final TransformerException
the exception to log.
e
)

Implements javax.xml.transform.ErrorListener.fatalError.

Log a fatal error.
private TransformerFactory

Returns:

the Transformer factory associated to this liaison.
getFactory
()

return the Transformer factory associated to this liaison.

private Source

Returns:

the configured source instance matching the stylesheet.
getSource
(final InputStream
the stream containing the stylesheet data.
is
,
final File
the file that will be used for the systemid.
infile
)

Get the source instance from the stream and id of the file.

private Source
getSource(final InputStream is, final Resource resource)

protected String

Returns:

the systemid
getSystemId
(final File
the filename to use for the systemid
file
)

Deprecated since 1.5.x. Use org.apache.tools.ant.util.JAXPUtils#getSystemId instead.
private void
logError(final TransformerException e, final String type)

private void
readTemplates()

Read in templates from the stylesheet

private String
resourceToURI(final Resource resource)

public void
setAttribute(final String
the attribute name.
name
,
final Object
the value of the attribute, usually a boolean string or object.
value
)

Set a custom attribute for the JAXP factory implementation.

public void
setEntityResolver(final EntityResolver
the resolver class.
aResolver
)

Set the class to resolve entities during the transformation.

public void
setFactory(final String
the fully qualified class name of the factory to use or null for the default JAXP look up mechanism.
name
)

Set the factory name to use instead of JAXP default lookup.

public void
setFeature(final String
the feature name.
name
,
final boolean
the value of the feature
value
)

Set a custom feature for the JAXP factory implementation.

public void
public void
setOutputProperty(final String
the output property name.
name
,
final String
the output property value.
value
)

Set the output property for the current transformer.

public void
setStylesheet(final File
a File value
stylesheet
)

Implements org.apache.tools.ant.taskdefs.XSLTLiaison.setStylesheet.

Set the stylesheet file.
public void
private void
setTransformationParameters()

Sets the parameters for the transformer.

public void
setURIResolver(final URIResolver
a EntityResolver value
aResolver
)

Set the class to resolve URIs during the transformation

public void
transform(final File
the file to transform
infile
,
final File
the result file
outfile
)

Implements org.apache.tools.ant.taskdefs.XSLTLiaison.transform.

Transform an input file.
public void
warning(final TransformerException
the exception to log.
e
)

Implements javax.xml.transform.ErrorListener.warning.

Log a warning.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private final List<Object[]> attributes

factory attributes

entityResolverback to summary
private EntityResolver entityResolver

possible resolver for publicIds

factoryNameback to summary
private String factoryName

the name of the factory implementation class to use or null for default JAXP lookup.

featuresback to summary
private final Map<String, Boolean> features

factory features

FILE_UTILSback to summary
private static final FileUtils FILE_UTILS

Helper for transforming filenames to URIs.

Since
Ant 1.7
loggerback to summary
private XSLTLogger logger
outputPropertiesback to summary
private final Vector<String[]> outputProperties

transformer output properties

paramsback to summary
private final Hashtable<String, Object> params

stylesheet parameters

projectback to summary
private Project project

The current Project

stylesheetback to summary
private Resource stylesheet

stylesheet to use for transformation

suppressWarningsback to summary
private boolean suppressWarnings

whether to suppress warnings

templatesback to summary
private Templates templates

The In memory version of the stylesheet

templatesModTimeback to summary
private long templatesModTime

The modification time of the stylesheet from which the templates are read

tfactoryback to summary
private TransformerFactory tfactory

The trax TransformerFactory

traceConfigurationback to summary
private XSLTProcess.TraceConfiguration traceConfiguration

optional trace configuration.

transformerback to summary
private Transformer transformer

transformer to use for processing files

uriResolverback to summary
private URIResolver uriResolver

possible resolver for URIs

Constructor Detail

TraXLiaisonback to summary
public TraXLiaison() throws Exception

Constructor for TraXLiaison.

Exceptions
Exception:
never

Method Detail

addParamback to summary
public void addParam(final String name, final String value)

Implements org.apache.tools.ant.taskdefs.XSLTLiaison.addParam.

Add a parameter.

Parameters
name:String

the name of the parameter

value:String

the value of the parameter

addParamback to summary
public void addParam(final String name, final Object value)

Implements org.apache.tools.ant.taskdefs.XSLTLiaison4.addParam.

Add a parameter.

Parameters
name:String

the name of the parameter

value:Object

the value of the parameter

Since
Ant 1.9.3
applyReflectionHackForExtensionMethodsback to summary
private void applyReflectionHackForExtensionMethods()
configureback to summary
public void configure(final XSLTProcess xsltTask)

Implements org.apache.tools.ant.taskdefs.XSLTLiaison2.configure.

Specific configuration for the TRaX liaison.

Parameters
xsltTask:XSLTProcess

the XSLTProcess task instance from which this liaison is to be configured.

createTransformerback to summary
private void createTransformer() throws IOException, ParserConfigurationException, SAXException, TransformerException

Create a new transformer based on the liaison settings

See Also
setStylesheet(java.io.File), addParam(java.lang.String, java.lang.String), setOutputProperty(java.lang.String, java.lang.String)
errorback to summary
public void error(final TransformerException e)

Implements javax.xml.transform.ErrorListener.error.

Log an error.

Parameters
e:TransformerException

the exception to log.

fatalErrorback to summary
public void fatalError(final TransformerException e)

Implements javax.xml.transform.ErrorListener.fatalError.

Log a fatal error.

Parameters
e:TransformerException

the exception to log.

getFactoryback to summary
private TransformerFactory getFactory() throws BuildException

return the Transformer factory associated to this liaison.

Returns:TransformerFactory

the Transformer factory associated to this liaison.

Exceptions
BuildException:
thrown if there is a problem creating the factory.
Since
Ant 1.5.2
See Also
setFactory(String)
getSourceback to summary
private Source getSource(final InputStream is, final File infile) throws ParserConfigurationException, SAXException

Get the source instance from the stream and id of the file.

Parameters
is:InputStream

the stream containing the stylesheet data.

infile:File

the file that will be used for the systemid.

Returns:Source

the configured source instance matching the stylesheet.

Exceptions
ParserConfigurationException:
if a parser cannot be created which satisfies the requested configuration.
SAXException:
in case of problem detected by the SAX parser.
getSourceback to summary
private Source getSource(final InputStream is, final Resource resource) throws ParserConfigurationException, SAXException
getSystemIdback to summary
protected String getSystemId(final File file)

Deprecated

since 1.5.x. Use org.apache.tools.ant.util.JAXPUtils#getSystemId instead.

Parameters
file:File

the filename to use for the systemid

Returns:String

the systemid

Annotations
@Deprecated
logErrorback to summary
private void logError(final TransformerException e, final String type)
readTemplatesback to summary
private void readTemplates() throws IOException, TransformerConfigurationException, ParserConfigurationException, SAXException

Read in templates from the stylesheet

resourceToURIback to summary
private String resourceToURI(final Resource resource)
setAttributeback to summary
public void setAttribute(final String name, final Object value)

Set a custom attribute for the JAXP factory implementation.

Parameters
name:String

the attribute name.

value:Object

the value of the attribute, usually a boolean string or object.

Since
Ant 1.6
setEntityResolverback to summary
public void setEntityResolver(final EntityResolver aResolver)

Set the class to resolve entities during the transformation.

Parameters
aResolver:EntityResolver

the resolver class.

setFactoryback to summary
public void setFactory(final String name)

Set the factory name to use instead of JAXP default lookup.

Parameters
name:String

the fully qualified class name of the factory to use or null for the default JAXP look up mechanism.

Since
Ant 1.6
setFeatureback to summary
public void setFeature(final String name, final boolean value)

Set a custom feature for the JAXP factory implementation.

Parameters
name:String

the feature name.

value:boolean

the value of the feature

Since
Ant 1.9.8
setLoggerback to summary
public void setLogger(final XSLTLogger l)

Implements org.apache.tools.ant.taskdefs.XSLTLoggerAware.setLogger.

Set a logger.

Parameters
l:XSLTLogger

a logger.

setOutputPropertyback to summary
public void setOutputProperty(final String name, final String value)

Set the output property for the current transformer. Note that the stylesheet must be set prior to calling this method.

Parameters
name:String

the output property name.

value:String

the output property value.

Since
Ant 1.5
setStylesheetback to summary
public void setStylesheet(final File stylesheet) throws Exception

Implements org.apache.tools.ant.taskdefs.XSLTLiaison.setStylesheet.

Set the stylesheet file.

Parameters
stylesheet:File

a File value

Exceptions
Exception:
on error
setStylesheetback to summary
public void setStylesheet(final Resource stylesheet) throws Exception

Implements org.apache.tools.ant.taskdefs.XSLTLiaison3.setStylesheet.

Set the stylesheet file.

Parameters
stylesheet:Resource

a org.apache.tools.ant.types.Resource value

Exceptions
Exception:
on error
setTransformationParametersback to summary
private void setTransformationParameters()

Sets the parameters for the transformer.

setURIResolverback to summary
public void setURIResolver(final URIResolver aResolver)

Set the class to resolve URIs during the transformation

Parameters
aResolver:URIResolver

a EntityResolver value

transformback to summary
public void transform(final File infile, final File outfile) throws Exception

Implements org.apache.tools.ant.taskdefs.XSLTLiaison.transform.

Transform an input file.

Parameters
infile:File

the file to transform

outfile:File

the result file

Exceptions
Exception:
on error
warningback to summary
public void warning(final TransformerException e)

Implements javax.xml.transform.ErrorListener.warning.

Log a warning.

Parameters
e:TransformerException

the exception to log.