net.sweetohm.ant.xml
Class XTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by net.sweetohm.ant.util.FileTask
              extended by net.sweetohm.ant.xml.XTask
All Implemented Interfaces:
java.lang.Cloneable, org.xml.sax.ErrorHandler

public class XTask
extends FileTask
implements org.xml.sax.ErrorHandler

XTask is an XSLT task using XT from James Clark.

Author:
Michel CASABIANCA

Field Summary
(package private)  java.util.Vector args
          The argument list
(package private)  java.lang.String extension
          Extension for processed files (defaults to .html)
(package private)  boolean force
          Force flag.
(package private) static com.jclark.xsl.sax.OutputMethodHandlerImpl handler
          Output handler for the XT processor
(package private)  java.lang.String style
          The stylesheet to use to process files
(package private)  java.lang.String todir
          The destination directory for transformed files
(package private)  java.lang.String tofile
          The transformed file.
(package private) static com.jclark.xsl.sax.XSLProcessorImpl xslprocessor
          XT processor.
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
XTask()
           
 
Method Summary
 void addArg(Arg arg)
          Add an argument for the processor.
 void error(org.xml.sax.SAXParseException e)
          Manage errors.
 void execute()
          Executes the task.
 void fatalError(org.xml.sax.SAXParseException e)
          Manage fatal errors.
protected static org.xml.sax.InputSource getInputSource(java.io.File file)
          Creates imput source
protected static org.xml.sax.Parser getParser()
          Builds the SAX parser for XT.
(package private)  void printSAXParseException(org.xml.sax.SAXParseException e)
          Print the SAX error message.
 void setExtension(java.lang.String extension)
          Extension setter.
 void setForce(boolean force)
          Setter for the force flag.
 void setStyle(java.lang.String style)
          Setter for the stylesheet to use for processing.
 void setTodir(java.lang.String todir)
          Setter for the output directory for processed files.
 void setTofile(java.lang.String tofile)
          Setter for the destination file.
 void warning(org.xml.sax.SAXParseException e)
          Manage warnings.
 
Methods inherited from class net.sweetohm.ant.util.FileTask
addFileset, getFiles, setDir, setFile
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xslprocessor

static com.jclark.xsl.sax.XSLProcessorImpl xslprocessor
XT processor. This field is static because only one processor is necessary. Should be reseted between calls ?


handler

static com.jclark.xsl.sax.OutputMethodHandlerImpl handler
Output handler for the XT processor


style

java.lang.String style
The stylesheet to use to process files


todir

java.lang.String todir
The destination directory for transformed files


tofile

java.lang.String tofile
The transformed file. This should be set only for the transformation of a single file


extension

java.lang.String extension
Extension for processed files (defaults to .html)


args

java.util.Vector args
The argument list


force

boolean force
Force flag. When it is set to true, the transformation is made even if the generated file is newer than the XML and XSLT files

Constructor Detail

XTask

public XTask()
Method Detail

setStyle

public void setStyle(java.lang.String style)
Setter for the stylesheet to use for processing.

Parameters:
style - The stylesheet to use.

setTodir

public void setTodir(java.lang.String todir)
Setter for the output directory for processed files.

Parameters:
todir - The directory for processed files.

setTofile

public void setTofile(java.lang.String tofile)
Setter for the destination file.

Parameters:
tofile - The processed files.

setExtension

public void setExtension(java.lang.String extension)
Extension setter.

Parameters:
extension - The extension to append to the generated file.

addArg

public void addArg(Arg arg)
Add an argument for the processor.

Parameters:
arg - The argument to pass to the processor.

setForce

public void setForce(boolean force)
Setter for the force flag.

Parameters:
force - The force tag. If true, the file is generated even if the xml or xsl are older.

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Executes the task.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

getParser

protected static org.xml.sax.Parser getParser()
Builds the SAX parser for XT. The Parser class is deprecated, but XT only knows anout those parsers. Note that the Parser class is deprecated, but we have no choice as XT uses it.

Returns:
the built parser

getInputSource

protected static org.xml.sax.InputSource getInputSource(java.io.File file)
Creates imput source

Parameters:
fileName - the file name for this source
Returns:
the build input source

warning

public void warning(org.xml.sax.SAXParseException e)
Manage warnings. Implements ErrorHandler interface.

Specified by:
warning in interface org.xml.sax.ErrorHandler

error

public void error(org.xml.sax.SAXParseException e)
Manage errors. Implements ErrorHandler interface.

Specified by:
error in interface org.xml.sax.ErrorHandler

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Manage fatal errors. Implements ErrorHandler interface.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

printSAXParseException

void printSAXParseException(org.xml.sax.SAXParseException e)
Print the SAX error message.