org.weborganic.schematron
Class ValidatorFactory

java.lang.Object
  extended by org.weborganic.schematron.ValidatorFactory

public final class ValidatorFactory
extends Object

A ValidatorFactory instance can be used to create a Validator object.


Nested Class Summary
static class ValidatorFactory.QueryBinding
           
 
Constructor Summary
ValidatorFactory()
          Constructs a new factory using the default preprocessor.
ValidatorFactory(Source preprocessor)
          Constructs a new factory object using the specified preprocessor.
ValidatorFactory(ValidatorFactory.QueryBinding binding, String formatter)
          Constructs a new ValidatorFactory object using the specified preprocessor.
 
Method Summary
 ErrorListener getErrorListener()
          Get the error event handler for this factory.
 Object getParameter(String name)
          Returns the parameters value for hte specified name.
 Validator newValidator(File schema)
          Process the specified schema into a Validator object.
 Validator newValidator(Source schema)
          Process the specified schema into a Validator object.
 void setDebugMode(boolean debugMode)
          If debug mode is set to true, then preprocessing stylesheet will be outputted in file debug.xslt This has to be called before newValidator() to take effect.
 void setErrorListener(ErrorListener listener)
          Set the error event listener for the ValidatorFactory, which is used for the processing of the Schematron schema, not for the Schematron validation itself.
 void setParameter(String name, Object value)
          Add a parameter to be sent to the preprocessor.
 void setResolver(Class<URIResolver> resolver)
          Set the class name of the resolver to use, overriding built-in Apache resolver
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatorFactory

public ValidatorFactory()
Constructs a new factory using the default preprocessor.


ValidatorFactory

public ValidatorFactory(Source preprocessor)
Constructs a new factory object using the specified preprocessor.

Parameters:
preprocessor - The preprocessor which generates the validating stylesheet.
Throws:
NullPointerException - If preprocessor is null.

ValidatorFactory

public ValidatorFactory(ValidatorFactory.QueryBinding binding,
                        String formatter)
Constructs a new ValidatorFactory object using the specified preprocessor.

Actually, this is not necessary.

Future versions may remove this so that only the SVRL is output.

Parameters:
preprocessor - The preprocessor which generates the validating stylesheet.
Throws:
IllegalArgumentException - If preprocessor is null.
Method Detail

setErrorListener

public void setErrorListener(ErrorListener listener)
Set the error event listener for the ValidatorFactory, which is used for the processing of the Schematron schema, not for the Schematron validation itself.

Parameters:
listener - The error listener.
Throws:
IllegalArgumentException - If listener is null.

getErrorListener

public ErrorListener getErrorListener()
Get the error event handler for this factory.

Returns:
The current error handler, which should never be null.

setParameter

public void setParameter(String name,
                         Object value)
Add a parameter to be sent to the preprocessor.

Parameters:
name - The name of the parameter.
value - The value object.
See Also:
Transformer.setParameter(String, Object)

getParameter

public Object getParameter(String name)
Returns the parameters value for hte specified name.

Parameters:
nameThe - name of the parameter.
Returns:
The parameter value or null if the parameter was not specified.

setDebugMode

public void setDebugMode(boolean debugMode)
If debug mode is set to true, then preprocessing stylesheet will be outputted in file debug.xslt This has to be called before newValidator() to take effect.


setResolver

public void setResolver(Class<URIResolver> resolver)
Set the class name of the resolver to use, overriding built-in Apache resolver


newValidator

public Validator newValidator(File schema)
                       throws SchematronException
Process the specified schema into a Validator object.

Parameters:
schema - The Schematron schema to use.
Returns:
A Validator instance for the specified schema.
Throws:
TransformerExceptionShould - an exception be while attempting to instantiate a validator.
SchematronException

newValidator

public Validator newValidator(Source schema)
                       throws SchematronException
Process the specified schema into a Validator object.

Parameters:
schema - The Schematron schema to use.
Returns:
A Validator instance for the specified schema.
Throws:
SchematronException - Will wrap any exception occurring while attempting to instantiate a validator.