org.custommonkey.xmlunit.jaxp13
Class Validator

java.lang.Object
  extended by org.custommonkey.xmlunit.jaxp13.Validator

public class Validator
extends java.lang.Object

Validator class based of javax.xml.validation.

This class provides support for validating schema definitions as well as instance documents. It defaults to the W3C XML Schema 1.0 but can be used to validate against any schema language supported by your SchemaFactory implementation.


Constructor Summary
  Validator()
          validates using W3C XML Schema 1.0.
  Validator(javax.xml.validation.SchemaFactory factory)
          validates using the specified schema factory.
  Validator(java.lang.String schemaLanguage)
          validates using the specified schema language.
protected Validator(java.lang.String schemaLanguage, javax.xml.validation.SchemaFactory factory)
          validates using the specified schema language or factory.
 
Method Summary
 void addSchemaSource(javax.xml.transform.Source s)
          Adds a source for the schema defintion.
 java.util.List getInstanceErrors(javax.xml.transform.Source instance)
          Obtain a list of all errors in the given instance.
 java.util.List getSchemaErrors()
          Obtain a list of all errors in the schema defintion.
 boolean isInstanceValid(javax.xml.transform.Source instance)
          Is the given schema instance valid according to the configured schema definition(s)?
 boolean isSchemaValid()
          Is the given schema definition valid?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Validator

public Validator()
validates using W3C XML Schema 1.0.


Validator

public Validator(java.lang.String schemaLanguage)
validates using the specified schema language.

Parameters:
schemaLanguage - the schema language to use - see SchemaFactory.

Validator

public Validator(javax.xml.validation.SchemaFactory factory)
validates using the specified schema factory.


Validator

protected Validator(java.lang.String schemaLanguage,
                    javax.xml.validation.SchemaFactory factory)
validates using the specified schema language or factory.

Parameters:
schemaLanguage - the schema language to use - see SchemaFactory.
schemaFactory - the concrete factory to use. If this is non-null, the first argument will be ignored.
Method Detail

addSchemaSource

public void addSchemaSource(javax.xml.transform.Source s)
Adds a source for the schema defintion.


isSchemaValid

public boolean isSchemaValid()
Is the given schema definition valid?


getSchemaErrors

public java.util.List getSchemaErrors()
Obtain a list of all errors in the schema defintion.

The list contains SAXParseExceptions.


isInstanceValid

public boolean isInstanceValid(javax.xml.transform.Source instance)
                        throws XMLUnitRuntimeException
Is the given schema instance valid according to the configured schema definition(s)?

Throws:
XMLUnitRuntimeException - if the schema definition is invalid or the Source is a SAXSource and the underlying XMLReader throws an IOException (see validate in Validator).

getInstanceErrors

public java.util.List getInstanceErrors(javax.xml.transform.Source instance)
                                 throws XMLUnitRuntimeException
Obtain a list of all errors in the given instance.

The list contains SAXParseExceptions.

Throws:
XMLUnitRuntimeException - if the schema definition is invalid or the Source is a SAXSource and the underlying XMLReader throws an IOException (see validate in Validator).

XMLUnit is hosted by sourceforge.net