org.apache.cocoon.components.validation.jaxp
Class JaxpSchemaParser

java.lang.Object
  extended by org.apache.cocoon.components.validation.impl.AbstractSchemaParser
      extended by org.apache.cocoon.components.validation.jaxp.JaxpSchemaParser
All Implemented Interfaces:
Disposable, Initializable, Configurable, LogEnabled, Serviceable, ThreadSafe, SchemaParser

public class JaxpSchemaParser
extends AbstractSchemaParser
implements Configurable, ThreadSafe

An implementation of the SchemaParser interface wrapping JAXP SchemaFactory instances.


Field Summary
 
Fields inherited from class org.apache.cocoon.components.validation.impl.AbstractSchemaParser
entityResolver, logger, serviceManager, sourceResolver
 
Fields inherited from interface org.apache.cocoon.components.validation.SchemaParser
ROLE
 
Constructor Summary
JaxpSchemaParser()
          Create a new JaxpSchemaParser instance.
 
Method Summary
 void configure(Configuration conf)
          Configure this instance.
 String[] getSupportedGrammars()
          Return an array of Strings containing all the grammar languages supported by this SchemaParser.
 Schema parseSchema(Source source, String grammar)
          Parse the specified Source and return a new Schema.
 
Methods inherited from class org.apache.cocoon.components.validation.impl.AbstractSchemaParser
dispose, enableLogging, initialize, service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxpSchemaParser

public JaxpSchemaParser()

Create a new JaxpSchemaParser instance.

Method Detail

configure

public void configure(Configuration conf)
               throws ConfigurationException

Configure this instance.

The JaxpSchemaParser requires at least one configuration element: <factory-class>class name</factory-class>. This specifies the JAXP SchemaFactory class to be used by this instance.

Grammars will be automatically detected if the SchemaFactory supports one of the RELAX-NG grammar, XML-Schema grammar, or the XML-DTD grammar.

If the factory is known to support different grammars, the default detection can be overridden specifying in the configuration something similar to the following:

   <grammars>
     <grammar>... a first grammar identifier ...</grammar>
     <grammar>... another grammar identifier ...</grammar>
   </grammars>
 

Specified by:
configure in interface Configurable
Throws:
ConfigurationException

parseSchema

public Schema parseSchema(Source source,
                          String grammar)
                   throws SAXException,
                          IOException

Parse the specified Source and return a new Schema.

The returned Schema must be able to validate multiple documents via multiple invocations of Schema.createValidator(ErrorHandler).

Specified by:
parseSchema in interface SchemaParser
Parameters:
source - the Source associated with the Schema to return.
Returns:
a non-null Schema instance.
Throws:
SAXException - if a grammar error occurred parsing the schema.
IOException - if an I/O error occurred parsing the schema.
IllegalArgumentException - if the specified grammar type is not one of the grammar types returned by the getSupportedGrammars() method.

getSupportedGrammars

public String[] getSupportedGrammars()
Description copied from interface: SchemaParser

Return an array of Strings containing all the grammar languages supported by this SchemaParser.

Specified by:
getSupportedGrammars in interface SchemaParser
Returns:
a non-null array of Strings.


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.