xdoclet.util
Class XmlValidator
DefaultHandler
xdoclet.util.XmlValidator
public class XmlValidator
extends DefaultHandler
This handler implementation is capable of providing dtds from a local storage instead of accessing them over the net.
Further, it will throw an exception if the parsed xml is not acording to the DTD it specifies.
- Deal with Translator.getString()'s exception better in resolveEntity(String, String)
XmlValidator(ClassLoader classLoader) - Describe what the XmlValidator constructor does
|
void | error(SAXParseException e) - Called by parser if a error occurs
|
static XmlValidator | getInstance() - Gets the Instance attribute of the XmlValidator class
|
void | registerDTD(String publicId, URL dtdURL) - Registers a local DTD document by its public id.
|
InputSource | resolveEntity(String publicId, String systemId) - Called by parser when a DTD declaration is encountered in the parsed XML document
|
static void | setInstance(XmlValidator instance) - Sets the Instance attribute of the XmlValidator class
|
void | validate(File xmlFile) - Validates an XML file for conformance to a declared DTD or XMLSchema.
|
void | warning(SAXParseException e) - Called by parser if a warning occurs
|
DEFAULT_XML_READER_CLASSNAME
public static final String DEFAULT_XML_READER_CLASSNAME
The crimson implementation is shipped with ant.
classLoader
protected ClassLoader classLoader
readerClassName
protected String readerClassName
xmlReader
protected XMLReader xmlReader
XMLReader used for validation
XmlValidator
public XmlValidator(ClassLoader classLoader)
Describe what the XmlValidator constructor does
classLoader
- Describe what the parameter does
error
public void error(SAXParseException e)
throws SAXParseException
Called by parser if a error occurs
e
- an exception describing the error
getInstance
public static XmlValidator getInstance()
Gets the Instance attribute of the XmlValidator class
registerDTD
public void registerDTD(String publicId,
URL dtdURL)
Registers a local DTD document by its public id. This is necessary to avoid DTD loading over the net.
publicId
- the publicId of the DTDdtdURL
- the URL of the local DTD, which must be loadable by the class passed in the constructor. This
URL typically points inside a local jar file
resolveEntity
public InputSource resolveEntity(String publicId,
String systemId)
Called by parser when a DTD declaration is encountered in the parsed XML document
publicId
- the public id of the DTDsystemId
- the system id of the DTD
- an InputSource from containing the DTD document, provided it has been previously registered via
the
registerDTD(String,URL)
method. If not, null will be returned, and the parser will atempt to load the DTD
from the systemId value, Usually an Internet http URL.
setInstance
public static void setInstance(XmlValidator instance)
Sets the Instance attribute of the XmlValidator class
instance
- The new Instance value
validate
public void validate(File xmlFile)
throws XDocletException
Validates an XML file for conformance to a declared DTD or XMLSchema. This method is useful for subclasses that
wish to verify that a generated XML file is ok. Please note that the callers should make sure to register any
DTDs required for validation on the handler object.
xmlFile
- Description of Parameter
warning
public void warning(SAXParseException e)
throws SAXParseException
Called by parser if a warning occurs
e
- an exception describing the warning