org.apache.tools.ant.taskdefs.optional
Class XMLValidateTask

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.tools.ant.taskdefs.optional.XMLValidateTask

public class XMLValidateTask
extends Task

The XMLValidateTask checks that an XML document is valid, with a SAX validating parser.

Author:
Raphael Pierquin raphael.pierquin@agisphere.com

Inner Class Summary
protected  class XMLValidateTask.ValidatorErrorHandler
           
 
Field Summary
protected  Path classpath
           
static java.lang.String DEFAULT_XML_READER_CLASSNAME
          The default implementation parser classname used by the task to process validation.
protected  XMLValidateTask.ValidatorErrorHandler errorHandler
           
protected  boolean failOnError
           
protected  java.util.Hashtable features
           
protected  java.io.File file
           
protected  java.util.Vector filesets
           
protected static java.lang.String INIT_FAILED_MSG
           
protected  boolean lenient
           
protected  java.lang.String readerClassName
           
protected  boolean warn
           
protected  org.xml.sax.XMLReader xmlReader
          the parser is viewed as a SAX2 XMLReader.
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
XMLValidateTask()
           
 
Method Summary
 void addFileset(FileSet set)
          specifify a set of file to be checked
 Path createClasspath()
           
 void execute()
          Called by the project to let the task do it's work.
 void setClassName(java.lang.String className)
          Specify the class name of the SAX parser to be used.
 void setClasspath(Path classpath)
          Specify the classpath to be searched to load the parser (optional)
 void setClasspathRef(Reference r)
           
 void setFailOnError(boolean fail)
          Specify how parser error are to be handled.
 void setFile(java.io.File file)
          specifify the file to be checked
 void setLenient(boolean bool)
          Specify whether the parser should be validating.
 void setWarn(boolean bool)
          Specify how parser error are to be handled.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_XML_READER_CLASSNAME

public static java.lang.String DEFAULT_XML_READER_CLASSNAME
The default implementation parser classname used by the task to process validation.

INIT_FAILED_MSG

protected static java.lang.String INIT_FAILED_MSG

failOnError

protected boolean failOnError

warn

protected boolean warn

lenient

protected boolean lenient

readerClassName

protected java.lang.String readerClassName

file

protected java.io.File file

filesets

protected java.util.Vector filesets

classpath

protected Path classpath

xmlReader

protected org.xml.sax.XMLReader xmlReader
the parser is viewed as a SAX2 XMLReader. If a SAX1 parser is specified, it's wrapped in an adapter that make it behave as a XMLReader. a more 'standard' way of doing this would be to use the JAXP1.1 SAXParser interface.

errorHandler

protected XMLValidateTask.ValidatorErrorHandler errorHandler

features

protected java.util.Hashtable features
Constructor Detail

XMLValidateTask

public XMLValidateTask()
Method Detail

setFailOnError

public void setFailOnError(boolean fail)
Specify how parser error are to be handled.

If set to true (default), throw a buildException if the parser yields an error.


setWarn

public void setWarn(boolean bool)
Specify how parser error are to be handled.

If set to true (default), log a warn message for each SAX warn event.


setLenient

public void setLenient(boolean bool)
Specify whether the parser should be validating. Default is true.

If set to false, the validation will fail only if the parsed document is not well formed XML.

this option is ignored if the specified class with setClassName(String) is not a SAX2 XMLReader.


setClassName

public void setClassName(java.lang.String className)
Specify the class name of the SAX parser to be used. (optional)
Parameters:
className - should be an implementation of SAX2 org.xml.sax.XMLReader or SAX2 org.xml.sax.Parser.

if className is an implementation of org.xml.sax.Parser, setLenient(boolean), will be ignored.

if not set, the default DEFAULT_XML_READER_CLASSNAME will be used.

See Also:
,

setClasspath

public void setClasspath(Path classpath)
Specify the classpath to be searched to load the parser (optional)

createClasspath

public Path createClasspath()
See Also:
#setClassPath

setClasspathRef

public void setClasspathRef(Reference r)
See Also:
#setClassPath

setFile

public void setFile(java.io.File file)
specifify the file to be checked

addFileset

public void addFileset(FileSet set)
specifify a set of file to be checked

execute

public void execute()
             throws BuildException
Description copied from class: Task
Called by the project to let the task do it's work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running "ant target1 target2" will run all tasks in target3 twice.
Overrides:
execute in class Task
Following copied from class: org.apache.tools.ant.Task
Throws:
BuildException - if someting goes wrong with the build


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.