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.Vectorattributesfactory attributesprivate org.xml.sax.EntityResolverentityResolverpossible resolver for publicIdsprivate java.lang.StringfactoryNamethe name of the factory implementation class to use or null for default JAXP lookup.private org.apache.tools.ant.taskdefs.XSLTLoggerloggerprivate java.util.VectoroutputPropertiestransformer output propertiesprivate java.util.Vectorparamsstylesheet parametersprivate java.io.Filestylesheetstylesheet to use for transformationprivate java.lang.StringsystemidThe systemid of the stylesheet (a URL).private javax.xml.transform.TemplatestemplatesThe In memory version of the stylesheetprivate longtemplatesModTimeThe modification time of the stylesheet from which the templates are readprivate javax.xml.transform.TransformerFactorytfactoryThe trax TransformerFactoryprivate javax.xml.transform.Transformertransformertransformer to use for processing filesprivate javax.xml.transform.URIResolveruriResolverpossible 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 voidaddParam(java.lang.String name, java.lang.String value)voidconfigure(org.apache.tools.ant.taskdefs.XSLTProcess xsltTask)Specific configuration for the TRaX liaison.voidconfigure(JDXSLTProcess xsltTask)Specific configuration for the TRaX liaison.private voidcreateTransformer()Create a new transformer based on the liaison settingsvoiderror(javax.xml.transform.TransformerException e)voidfatalError(javax.xml.transform.TransformerException e)private javax.xml.transform.TransformerFactorygetFactory()return the Transformer factory associated to this liaison.private javax.xml.transform.SourcegetSource(java.io.InputStream is, java.io.File infile)Get the source instance from the stream and id of the file.private javax.xml.transform.SourcegetSource(java.io.InputStream is, java.lang.String systemid)protected java.lang.StringgetSystemId(java.io.File file)Deprecated.use org.apache.tools.ant.util.JAXPUtils#getSystemId insteadprivate voidlogError(javax.xml.transform.TransformerException e, java.lang.String type)private voidreadTemplates()Read in templates from the stylesheetvoidsetAttribute(java.lang.String name, java.lang.Object value)Set a custom attribute for the JAXP factory implementation.voidsetEntityResolver(org.xml.sax.EntityResolver aResolver)Set the class to resolve entities during the transformationvoidsetFactory(java.lang.String name)Set the factory name to use instead of JAXP default lookup.voidsetLogger(org.apache.tools.ant.taskdefs.XSLTLogger l)voidsetOutputProperty(java.lang.String name, java.lang.String value)Set the output property for the current transformer.voidsetStylesheet(java.io.File stylesheet)voidsetStylesheet(java.lang.String systemid)Set the stylesheet to use for the transformation.voidsetURIResolver(javax.xml.transform.URIResolver aResolver)Set the class to resolve URIs during the transformationvoidtransform(java.io.File infile, java.io.File outfile)voidwarning(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:JDXSLTLiaison3Set the stylesheet to use for the transformation.- Specified by:
setStylesheetin interfaceJDXSLTLiaison3- Parameters:
systemid- the systemid of the stylesheet (a URL).
-
setStylesheet
public void setStylesheet(java.io.File stylesheet) throws java.lang.Exception- Specified by:
setStylesheetin 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:
transformin 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.SAXExceptionGet 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.ParserConfigurationExceptionorg.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.ParserConfigurationExceptionorg.xml.sax.SAXException
-
readTemplates
private void readTemplates() throws java.io.IOException, javax.xml.transform.TransformerConfigurationException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXExceptionRead in templates from the stylesheet- Throws:
java.io.IOExceptionjavax.xml.transform.TransformerConfigurationExceptionjavax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXException
-
createTransformer
private void createTransformer() throws java.lang.ExceptionCreate 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.BuildExceptionreturn 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:
addParamin interfaceorg.apache.tools.ant.taskdefs.XSLTLiaison
-
setLogger
public void setLogger(org.apache.tools.ant.taskdefs.XSLTLogger l)
- Specified by:
setLoggerin interfaceorg.apache.tools.ant.taskdefs.XSLTLoggerAware
-
error
public void error(javax.xml.transform.TransformerException e)
- Specified by:
errorin interfacejavax.xml.transform.ErrorListener
-
fatalError
public void fatalError(javax.xml.transform.TransformerException e)
- Specified by:
fatalErrorin interfacejavax.xml.transform.ErrorListener
-
warning
public void warning(javax.xml.transform.TransformerException e)
- Specified by:
warningin 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:
configurein 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:
configurein interfaceJDXSLTLiaison3- Parameters:
xsltTask- the XSLTProcess task instance from which this liasion is to be configured.
-
-