com.thaiopensource.validate.schematron
Class SchemaReaderImpl

java.lang.Object
  extended by com.thaiopensource.validate.schematron.SchemaReaderImpl
All Implemented Interfaces:
SchemaReader

 class SchemaReaderImpl
extends Object
implements SchemaReader


Nested Class Summary
(package private) static class SchemaReaderImpl.ErrorFilter
           
(package private) static class SchemaReaderImpl.LocationFilter
           
(package private) static class SchemaReaderImpl.SAXErrorListener
           
(package private) static class SchemaReaderImpl.TransformStage
           
(package private) static class SchemaReaderImpl.UserException
           
(package private) static class SchemaReaderImpl.UserWrapErrorHandler
           
(package private) static class SchemaReaderImpl.ValidateStage
           
 
Field Summary
private static String ERROR_URI
           
private  Localizer localizer
           
private static String LOCATION_URI
           
private  Templates schematron
           
private static String SCHEMATRON_SCHEMA
           
private static String SCHEMATRON_STYLESHEET
           
(package private) static String SCHEMATRON_URI
           
private  Schema schematronSchema
           
private static PropertyId[] supportedPropertyIds
           
private  Class transformerFactoryClass
           
 
Fields inherited from interface com.thaiopensource.validate.SchemaReader
BASE_URI
 
Constructor Summary
SchemaReaderImpl(TransformerFactory transformerFactory)
           
 
Method Summary
private  SAXException causeToSAXException(Throwable cause, boolean hadError)
           
 Schema createSchema(InputSource in, PropertyMap properties)
          Creates a Schema by reading it from an InputSource.
private  SAXSource createTransformingSource(SAXSource in, String phase, boolean diagnose, String systemId, CountingErrorHandler ceh)
           
private  SAXSource createValidatingSource(InputSource in, PropertyMap properties, CountingErrorHandler ceh)
           
private static String fullResourceName(String name)
           
 Option getOption(String uri)
           
private static InputStream getResourceAsStream(String resourceName)
           
private  void initTransformerFactory(TransformerFactory factory)
           
private static SAXException toSAXException(SchemaReaderImpl.UserException e)
           
private  SAXException toSAXException(TransformerException e, boolean hadError)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEMATRON_URI

static final String SCHEMATRON_URI
See Also:
Constant Field Values

LOCATION_URI

private static final String LOCATION_URI
See Also:
Constant Field Values

ERROR_URI

private static final String ERROR_URI
See Also:
Constant Field Values

localizer

private final Localizer localizer

transformerFactoryClass

private final Class transformerFactoryClass

schematron

private final Templates schematron

schematronSchema

private final Schema schematronSchema

SCHEMATRON_SCHEMA

private static final String SCHEMATRON_SCHEMA
See Also:
Constant Field Values

SCHEMATRON_STYLESHEET

private static final String SCHEMATRON_STYLESHEET
See Also:
Constant Field Values

supportedPropertyIds

private static final PropertyId[] supportedPropertyIds
Constructor Detail

SchemaReaderImpl

SchemaReaderImpl(TransformerFactory transformerFactory)
           throws TransformerConfigurationException,
                  IncorrectSchemaException
Throws:
TransformerConfigurationException
IncorrectSchemaException
Method Detail

getOption

public Option getOption(String uri)
Specified by:
getOption in interface SchemaReader

initTransformerFactory

private void initTransformerFactory(TransformerFactory factory)

createSchema

public Schema createSchema(InputSource in,
                           PropertyMap properties)
                    throws IOException,
                           SAXException,
                           IncorrectSchemaException
Description copied from interface: SchemaReader
Creates a Schema by reading it from an InputSource.

Specified by:
createSchema in interface SchemaReader
Parameters:
in - the InputSource from which to read the schema; must not be null
properties - a PropertyMap to control the schema creation; must not be null
Returns:
a newly created Schema, never null
Throws:
IOException - if an I/O error occurs
SAXException
IncorrectSchemaException
See Also:
ValidateProperty

createValidatingSource

private SAXSource createValidatingSource(InputSource in,
                                         PropertyMap properties,
                                         CountingErrorHandler ceh)
                                  throws SAXException
Throws:
SAXException

createTransformingSource

private SAXSource createTransformingSource(SAXSource in,
                                           String phase,
                                           boolean diagnose,
                                           String systemId,
                                           CountingErrorHandler ceh)
                                    throws SAXException
Throws:
SAXException

toSAXException

private SAXException toSAXException(TransformerException e,
                                    boolean hadError)
                             throws IOException,
                                    IncorrectSchemaException
Throws:
IOException
IncorrectSchemaException

causeToSAXException

private SAXException causeToSAXException(Throwable cause,
                                         boolean hadError)
                                  throws IOException,
                                         IncorrectSchemaException
Throws:
IOException
IncorrectSchemaException

toSAXException

private static SAXException toSAXException(SchemaReaderImpl.UserException e)
                                    throws IOException,
                                           IncorrectSchemaException
Throws:
IOException
IncorrectSchemaException

fullResourceName

private static String fullResourceName(String name)

getResourceAsStream

private static InputStream getResourceAsStream(String resourceName)