| java.lang.Object org.xml.sax.helpers.DefaultHandler org.custommonkey.xmlunit.Validator
Validator | public class Validator extends DefaultHandler implements ErrorHandler(Code) | | Validates XML against its internal or external DOCTYPE, or a completely
different DOCTYPE.
Usage:
new Validator(readerForXML);
to validate some XML that contains or references an accessible DTD or
schema
new Validator(readerForXML, systemIdForValidation);
to validate some XML that references a DTD but using a local systemId
to perform the validation
new Validator(readerForXML, systemIdForValidation, doctypeName);
to validate some XML against a completely different DTD
Examples and more at xmlunit.sourceforge.net
|
Constructor Summary | |
protected | Validator(InputSource inputSource, boolean usingDoctypeReader) Kept for backwards compatibility. | protected | Validator(InputSource inputSource, String systemId, boolean usingDoctypeReader) | public | Validator(Document document, String systemID, String doctype) DOM-style constructor: allows Document validation post-manipulation
of the DOM tree's contents. | public | Validator(Reader readerForValidation) Basic constructor. | public | Validator(String stringForValidation) Basic constructor. | public | Validator(InputSource sourceForValidation) Basic constructor. | public | Validator(Reader readerForValidation, String systemID) Extended constructor.
Validates the contents of the Reader using the DTD specified with the
systemID. | public | Validator(String stringForValidation, String systemID) Extended constructor.
Validates the contents of the String using the DTD specified with the
systemID. | public | Validator(InputSource sourceForValidation, String systemID) Extended constructor.
Validates the contents of the InputSource using the DTD
specified with the systemID. | public | Validator(InputSource sourceForValidation, String systemID, String doctype) Full constructor. | public | Validator(Reader readerForValidation, String systemID, String doctype) Full constructor. |
Validator | public Validator(Document document, String systemID, String doctype) throws SAXException, ConfigurationException(Code) | | DOM-style constructor: allows Document validation post-manipulation
of the DOM tree's contents.
This takes a fairly tortuous route to validation as DOM level 2 does
not allow creation of Doctype nodes.
The supplied systemId and doctype name will replace any Doctype
settings in the Document.
Parameters: document - Parameters: systemID - Parameters: doctype - throws: SAXException - if unable to obtain new Sax parser via JAXP factory throws: ConfigurationException - if validation could not be turned on |
Validator | public Validator(Reader readerForValidation, String systemID) throws SAXException, ConfigurationException(Code) | | Extended constructor.
Validates the contents of the Reader using the DTD specified with the
systemID. There must be DOCTYPE instruction in the markup that
references the DTD or else the markup will be considered invalid: if
there is no DOCTYPE in the markup use the 3-argument constructor
Parameters: readerForValidation - Parameters: systemID - throws: SAXException - if unable to obtain new Sax parser via JAXP factory throws: ConfigurationException - if validation could not be turned on |
Validator | public Validator(String stringForValidation, String systemID) throws SAXException, ConfigurationException(Code) | | Extended constructor.
Validates the contents of the String using the DTD specified with the
systemID. There must be DOCTYPE instruction in the markup that
references the DTD or else the markup will be considered invalid: if
there is no DOCTYPE in the markup use the 3-argument constructor
Parameters: stringForValidation - Parameters: systemID - throws: SAXException - if unable to obtain new Sax parser via JAXP factory throws: ConfigurationException - if validation could not be turned on |
Validator | public Validator(InputSource sourceForValidation, String systemID) throws SAXException, ConfigurationException(Code) | | Extended constructor.
Validates the contents of the InputSource using the DTD
specified with the systemID. There must be DOCTYPE instruction
in the markup that references the DTD or else the markup will
be considered invalid: if there is no DOCTYPE in the markup use
the 3-argument constructor
Parameters: sourceForValidation - Parameters: systemID - throws: SAXException - if unable to obtain new Sax parser via JAXP factory throws: ConfigurationException - if validation could not be turned on |
assertIsValid | public void assertIsValid()(Code) | | Assert that a document is valid.
|
isValid | public boolean isValid()(Code) | | Perform the validation of the source against DTD / Schema.
true if the input supplied to the constructor passes validation,false otherwise |
resolveEntity | public InputSource resolveEntity(String publicId, String systemId)(Code) | | Entity Resolver method: allows us to override an existing systemID
referenced in the markup DOCTYPE instruction.
Parameters: publicId - Parameters: systemId - the sax InputSource that points to the overridden systemID |
setJAXP12SchemaSource | public void setJAXP12SchemaSource(Object schemaSource) throws SAXException(Code) | | As per JAXP 1.2 changes, which introduced a standard way for parsers to
support schema validation. Since only W3C Schema support was included in
JAXP 1.2, this is the only mechanism currently supported by this method.
Parameters: schemaSource - This can be one of the following:- String that points to the URI of the schema
- InputStream with the contents of the schema
- SAX InputSource
- File
- an array of Objects with the contents being one of thetypes defined above. An array of Objects can be used only whenthe schema language has the ability to assemble a schema atruntime. When an array of Objects is passed it is illegal tohave two schemas that share the same namespace.
throws: SAXException - if this method of validating isn't supported. See Also: http://java.sun.com/webservices/jaxp/change-requests-11.html |
toString | public String toString()(Code) | | class name appended with validation messages |
useXMLSchema | public void useXMLSchema(boolean use) throws SAXException(Code) | | Turn on XML Schema validation.
This feature should work with any XML parser that is JAXP
1.2 compliant and supports XML Schema validation.
For a fully JAXP 1.2 compliant parser the property
JAXPConstants.Properties.SCHEMA_LANGUAGEhttp://java.sun.com/xml/jaxp/properties/schemaLanguage is set,
if this fails the method falls back to the features
http://apache.org/xml/features/validation/schema &
http://apache.org/xml/features/validation/dynamic which should
cover early versions of Xerces 2 as well.
Parameters: use - indicate that XML Schema should be used to validatedocuments. throws: SAXException - See Also: Validator.setJAXP12SchemaSource(Object) |
Methods inherited from org.xml.sax.helpers.DefaultHandler | public void characters(char ch, int start, int length) throws SAXException(Code)(Java Doc) public void endDocument() throws SAXException(Code)(Java Doc) public void endElement(String uri, String localName, String qName) throws SAXException(Code)(Java Doc) public void endPrefixMapping(String prefix) throws SAXException(Code)(Java Doc) public void error(SAXParseException e) throws SAXException(Code)(Java Doc) public void fatalError(SAXParseException e) throws SAXException(Code)(Java Doc) public void ignorableWhitespace(char ch, int start, int length) throws SAXException(Code)(Java Doc) public void notationDecl(String name, String publicId, String systemId) throws SAXException(Code)(Java Doc) public void processingInstruction(String target, String data) throws SAXException(Code)(Java Doc) public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException(Code)(Java Doc) public void setDocumentLocator(Locator locator)(Code)(Java Doc) public void skippedEntity(String name) throws SAXException(Code)(Java Doc) public void startDocument() throws SAXException(Code)(Java Doc) public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException(Code)(Java Doc) public void startPrefixMapping(String prefix, String uri) throws SAXException(Code)(Java Doc) public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException(Code)(Java Doc) public void warning(SAXParseException e) throws SAXException(Code)(Java Doc)
|
|
|