Package org.osjava.jardiff.ant
Class JDTraXLiaison
- java.lang.Object
-
- org.osjava.jardiff.ant.JDTraXLiaison
-
- All Implemented Interfaces:
javax.xml.transform.ErrorListener
,org.apache.tools.ant.taskdefs.XSLTLiaison
,org.apache.tools.ant.taskdefs.XSLTLiaison2
,org.apache.tools.ant.taskdefs.XSLTLoggerAware
,JDXSLTLiaison3
public class JDTraXLiaison extends java.lang.Object implements JDXSLTLiaison3, javax.xml.transform.ErrorListener, org.apache.tools.ant.taskdefs.XSLTLoggerAware
Custom TraX liaison class. This allows loading a stylesheet from a systemid (URL).
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Vector
attributes
factory attributesprivate org.xml.sax.EntityResolver
entityResolver
possible resolver for publicIdsprivate java.lang.String
factoryName
the name of the factory implementation class to use or null for default JAXP lookup.private org.apache.tools.ant.taskdefs.XSLTLogger
logger
private java.util.Vector
outputProperties
transformer output propertiesprivate java.util.Vector
params
stylesheet parametersprivate java.io.File
stylesheet
stylesheet to use for transformationprivate java.lang.String
systemid
The systemid of the stylesheet (a URL).private javax.xml.transform.Templates
templates
The In memory version of the stylesheetprivate long
templatesModTime
The modification time of the stylesheet from which the templates are readprivate javax.xml.transform.TransformerFactory
tfactory
The trax TransformerFactoryprivate javax.xml.transform.Transformer
transformer
transformer to use for processing filesprivate javax.xml.transform.URIResolver
uriResolver
possible resolver for URIs
-
Constructor Summary
Constructors Constructor Description JDTraXLiaison()
Create a new JDTraXLiaison.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addParam(java.lang.String name, java.lang.String value)
void
configure(org.apache.tools.ant.taskdefs.XSLTProcess xsltTask)
Specific configuration for the TRaX liaison.void
configure(JDXSLTProcess xsltTask)
Specific configuration for the TRaX liaison.private void
createTransformer()
Create a new transformer based on the liaison settingsvoid
error(javax.xml.transform.TransformerException e)
void
fatalError(javax.xml.transform.TransformerException e)
private javax.xml.transform.TransformerFactory
getFactory()
return the Transformer factory associated to this liaison.private javax.xml.transform.Source
getSource(java.io.InputStream is, java.io.File infile)
Get the source instance from the stream and id of the file.private javax.xml.transform.Source
getSource(java.io.InputStream is, java.lang.String systemid)
protected java.lang.String
getSystemId(java.io.File file)
Deprecated.use org.apache.tools.ant.util.JAXPUtils#getSystemId insteadprivate void
logError(javax.xml.transform.TransformerException e, java.lang.String type)
private void
readTemplates()
Read in templates from the stylesheetvoid
setAttribute(java.lang.String name, java.lang.Object value)
Set a custom attribute for the JAXP factory implementation.void
setEntityResolver(org.xml.sax.EntityResolver aResolver)
Set the class to resolve entities during the transformationvoid
setFactory(java.lang.String name)
Set the factory name to use instead of JAXP default lookup.void
setLogger(org.apache.tools.ant.taskdefs.XSLTLogger l)
void
setOutputProperty(java.lang.String name, java.lang.String value)
Set the output property for the current transformer.void
setStylesheet(java.io.File stylesheet)
void
setStylesheet(java.lang.String systemid)
Set the stylesheet to use for the transformation.void
setURIResolver(javax.xml.transform.URIResolver aResolver)
Set the class to resolve URIs during the transformationvoid
transform(java.io.File infile, java.io.File outfile)
void
warning(javax.xml.transform.TransformerException e)
-
-
-
Field Detail
-
systemid
private java.lang.String systemid
The systemid of the stylesheet (a URL).
-
factoryName
private java.lang.String factoryName
the name of the factory implementation class to use or null for default JAXP lookup.
-
tfactory
private javax.xml.transform.TransformerFactory tfactory
The trax TransformerFactory
-
stylesheet
private java.io.File stylesheet
stylesheet to use for transformation
-
logger
private org.apache.tools.ant.taskdefs.XSLTLogger logger
-
entityResolver
private org.xml.sax.EntityResolver entityResolver
possible resolver for publicIds
-
transformer
private javax.xml.transform.Transformer transformer
transformer to use for processing files
-
templates
private javax.xml.transform.Templates templates
The In memory version of the stylesheet
-
templatesModTime
private long templatesModTime
The modification time of the stylesheet from which the templates are read
-
uriResolver
private javax.xml.transform.URIResolver uriResolver
possible resolver for URIs
-
outputProperties
private java.util.Vector outputProperties
transformer output properties
-
params
private java.util.Vector params
stylesheet parameters
-
attributes
private java.util.Vector attributes
factory attributes
-
-
Method Detail
-
setStylesheet
public void setStylesheet(java.lang.String systemid)
Description copied from interface:JDXSLTLiaison3
Set the stylesheet to use for the transformation.- Specified by:
setStylesheet
in interfaceJDXSLTLiaison3
- Parameters:
systemid
- the systemid of the stylesheet (a URL).
-
setStylesheet
public void setStylesheet(java.io.File stylesheet) throws java.lang.Exception
- Specified by:
setStylesheet
in interfaceorg.apache.tools.ant.taskdefs.XSLTLiaison
- Throws:
java.lang.Exception
-
transform
public void transform(java.io.File infile, java.io.File outfile) throws java.lang.Exception
- Specified by:
transform
in interfaceorg.apache.tools.ant.taskdefs.XSLTLiaison
- Throws:
java.lang.Exception
-
getSource
private javax.xml.transform.Source getSource(java.io.InputStream is, java.io.File infile) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
Get the source instance from the stream and id of the file.- Parameters:
is
- the stream containing the stylesheet data.infile
- the file that will be used for the systemid.- Returns:
- the configured source instance matching the stylesheet.
- Throws:
java.lang.Exception
- if there is a problem creating the source.javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
-
getSource
private javax.xml.transform.Source getSource(java.io.InputStream is, java.lang.String systemid) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
- Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
-
readTemplates
private void readTemplates() throws java.io.IOException, javax.xml.transform.TransformerConfigurationException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
Read in templates from the stylesheet- Throws:
java.io.IOException
javax.xml.transform.TransformerConfigurationException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
-
createTransformer
private void createTransformer() throws java.lang.Exception
Create a new transformer based on the liaison settings- Throws:
java.lang.Exception
- thrown if there is an error during creation.- See Also:
setStylesheet(java.io.File)
,addParam(java.lang.String, java.lang.String)
,setOutputProperty(java.lang.String, java.lang.String)
-
getFactory
private javax.xml.transform.TransformerFactory getFactory() throws org.apache.tools.ant.BuildException
return the Transformer factory associated to this liaison.- Returns:
- the Transformer factory associated to this liaison.
- Throws:
org.apache.tools.ant.BuildException
- thrown if there is a problem creating the factory.- Since:
- Ant 1.5.2
- See Also:
setFactory(String)
-
setFactory
public void setFactory(java.lang.String name)
Set the factory name to use instead of JAXP default lookup.- Parameters:
name
- the fully qualified class name of the factory to use or null for the default JAXP look up mechanism.- Since:
- Ant 1.6
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
Set a custom attribute for the JAXP factory implementation.- Parameters:
name
- the attribute name.value
- the value of the attribute, usually a boolean string or object.- Since:
- Ant 1.6
-
setOutputProperty
public void setOutputProperty(java.lang.String name, java.lang.String value)
Set the output property for the current transformer. Note that the stylesheet must be set prior to calling this method.- Parameters:
name
- the output property name.value
- the output property value.- Since:
- Ant 1.5, Ant 1.5
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver aResolver)
Set the class to resolve entities during the transformation
-
setURIResolver
public void setURIResolver(javax.xml.transform.URIResolver aResolver)
Set the class to resolve URIs during the transformation
-
addParam
public void addParam(java.lang.String name, java.lang.String value)
- Specified by:
addParam
in interfaceorg.apache.tools.ant.taskdefs.XSLTLiaison
-
setLogger
public void setLogger(org.apache.tools.ant.taskdefs.XSLTLogger l)
- Specified by:
setLogger
in interfaceorg.apache.tools.ant.taskdefs.XSLTLoggerAware
-
error
public void error(javax.xml.transform.TransformerException e)
- Specified by:
error
in interfacejavax.xml.transform.ErrorListener
-
fatalError
public void fatalError(javax.xml.transform.TransformerException e)
- Specified by:
fatalError
in interfacejavax.xml.transform.ErrorListener
-
warning
public void warning(javax.xml.transform.TransformerException e)
- Specified by:
warning
in interfacejavax.xml.transform.ErrorListener
-
logError
private void logError(javax.xml.transform.TransformerException e, java.lang.String type)
-
getSystemId
protected java.lang.String getSystemId(java.io.File file)
Deprecated.use org.apache.tools.ant.util.JAXPUtils#getSystemId instead
-
configure
public void configure(org.apache.tools.ant.taskdefs.XSLTProcess xsltTask)
Specific configuration for the TRaX liaison.- Specified by:
configure
in interfaceorg.apache.tools.ant.taskdefs.XSLTLiaison2
- Parameters:
xsltTask
- the XSLTProcess task instance from which this liasion is to be configured.
-
configure
public void configure(JDXSLTProcess xsltTask)
Specific configuration for the TRaX liaison.- Specified by:
configure
in interfaceJDXSLTLiaison3
- Parameters:
xsltTask
- the XSLTProcess task instance from which this liasion is to be configured.
-
-