net.sweetohm.ant.xml
Class ValidTask

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.ValidTask
All Implemented Interfaces:
java.lang.Cloneable

public class ValidTask
extends FileTask

Valid is an XML validator (can check well formness and validity).

Version:
1.0
Author:
Michel CASABIANCA

Nested Class Summary
(package private)  class ValidTask.Handler
          A class to handle parsing errors.
(package private)  class ValidTask.SAXParsingInterruptedException
          This exception is thrown when the parsing is interrupted due to to a number of errors greater than the allowed maximum.
 
Field Summary
(package private)  boolean dtd
          DTD loading flag
(package private) static int ERROR
           
(package private)  int errorCount
          The number of errors
(package private)  int errorlevel
           
(package private)  boolean failonerror
          Fail on error flag.
(package private) static int FATAL
           
(package private) static java.lang.String FILE
          The file prefix for system ID
(package private)  int maxerrors
          The maximum number of errors
(package private) static int WARNING
          The error level to generate an error: - warning [0]: a warning is an error (shown and may stop processing).
 
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
ValidTask()
           
 
Method Summary
 void execute()
          Executes the task.
(package private)  javax.xml.parsers.SAXParser getParser()
          Builds the SAX parser for parsing.
 void setDtd(boolean dtd)
          Setter for the DTD loading.
 void setErrorlevel(java.lang.String errorlevel)
          Error level setter (possible values are 'warning', 'error' or 'fatal').
 void setFailonerror(boolean failonerror)
          Setter for the failonerror flag.If true, the Ant compilation stops with an error message if the document being validated is not valid.
 void setMaxerrors(java.lang.String maxerrors)
          Maximum errors setter.
 
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

dtd

boolean dtd
DTD loading flag


failonerror

boolean failonerror
Fail on error flag. If true, the ant compilation stops on error


WARNING

static final int WARNING
The error level to generate an error: - warning [0]: a warning is an error (shown and may stop processing). - error [1]: same for errors. - fatal [2]: is the default value.

See Also:
Constant Field Values

ERROR

static final int ERROR
See Also:
Constant Field Values

FATAL

static final int FATAL
See Also:
Constant Field Values

errorlevel

int errorlevel

FILE

static final java.lang.String FILE
The file prefix for system ID

See Also:
Constant Field Values

errorCount

int errorCount
The number of errors


maxerrors

int maxerrors
The maximum number of errors

Constructor Detail

ValidTask

public ValidTask()
Method Detail

setDtd

public void setDtd(boolean dtd)
Setter for the DTD loading. If true, the DTD is loaded for validation. Defaults to true.

Parameters:
dtd - a boolean value

setFailonerror

public void setFailonerror(boolean failonerror)
Setter for the failonerror flag.If true, the Ant compilation stops with an error message if the document being validated is not valid. Defaults to true.

Parameters:
failonerror - Flag for failonerror flag.

setErrorlevel

public void setErrorlevel(java.lang.String errorlevel)
Error level setter (possible values are 'warning', 'error' or 'fatal'). The default value is 'fatal'.

Parameters:
errorlevel - The error level.

setMaxerrors

public void setMaxerrors(java.lang.String maxerrors)
Maximum errors setter.

Parameters:
maxerrors - The maximum number of errors to display for a given file.

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 - if an error occurs

getParser

javax.xml.parsers.SAXParser getParser()
Builds the SAX parser for parsing.

Returns:
The built parser