org.w3c.tidy.ant

Class JTidyTask


public class JTidyTask
extends Task

JTidy ant task.

Parameters

AttributeDescriptionRequired
srcfilesource fileYes, unless a nested <fileset> element is used.
destfiledestination file for outputWith the srcfile attribute, either destfile or destdir can be used. With nested <fileset> elements only destdir is allowed.
destdirdestination directory for output
propertiesPath to a valid tidy properties fileNo
flattenIgnore the directory structure of the source files, and copy all files into the directory specified by the destdir attribute.No; defaults to false.
failonerrorboolean to control whether failure to execute should throw a BuildException or just print an error. If set to true errors in input files which tidy is enable to fix will cause a failure.No; defaults to false.

Nested elements

Setup

Adds the following typedef to setup the JTidy task in your build.xml:

 <taskdef name="tidy" classname="org.w3c.tidy.ant.JTidyTask"/>
 

This will work if JTidy jar is copied to ant lib directory. If you need to reference the jar elsewhere on the filesystem you can add a nested classpath element:

 <taskdef name="tidy" classname="org.w3c.tidy.ant.JTidyTask">
   <classpath>
     <pathelement location="${lib.dir}/jtidy.jar"/>
   </classpath>
 </taskdef>
 

Examples

 <tidy destdir="out" properties="/path/to/tidy.properties">
   <fileset dir="inputdir" />
   <parameter name="drop-font-tags" value="true" />
 &lt/tidy>
 
Version:
$Revision: 807 $ ($Author: fgiust $)
Author:
Fabrizio Giustina

Method Summary

void
addConfiguredParameter(Parameter prop)
Setter method for any property using the ant type Parameter.
void
addFileset(FileSet fileSet)
Adds a fileset to be processed Fileset
void
execute()
Run the task.
protected void
executeSet()
Run tidy on filesets.
protected void
executeSingle()
A single file has been specified.
void
init()
Initializes the task.
protected void
processFile(File inputFile, File outputFile)
Run tidy on a file.
void
setDestdir(File destdir)
void
setDestfile(File destfile)
void
setFailonerror(boolean failonerror)
void
setFlatten(boolean flatten)
void
setProperties(File properties)
void
setSrcfile(File srcfile)
protected void
validateParameters()
Validates task parameters.

Method Details

addConfiguredParameter

public void addConfiguredParameter(Parameter prop)
Setter method for any property using the ant type Parameter.
Parameters:
prop - Ant type Parameter

addFileset

public void addFileset(FileSet fileSet)
Adds a fileset to be processed Fileset
Parameters:
fileSet -

execute

public void execute()
            throws BuildException
Run the task.

executeSet

protected void executeSet()
Run tidy on filesets.

executeSingle

protected void executeSingle()
A single file has been specified.

init

public void init()
Initializes the task.

processFile

protected void processFile(File inputFile,
                           File outputFile)
Run tidy on a file.
Parameters:
inputFile - input file
outputFile - output file

setDestdir

public void setDestdir(File destdir)
Parameters:
destdir - The destdir to set.

setDestfile

public void setDestfile(File destfile)
Parameters:
destfile - The destfile to set.

setFailonerror

public void setFailonerror(boolean failonerror)
Parameters:
failonerror - The failonerror to set.

setFlatten

public void setFlatten(boolean flatten)
Parameters:
flatten - The flatten to set.

setProperties

public void setProperties(File properties)
Parameters:
properties - The properties to set.

setSrcfile

public void setSrcfile(File srcfile)
Parameters:
srcfile - The srcfile to set.

validateParameters

protected void validateParameters()
            throws BuildException
Validates task parameters.