Class JaxpSchemaParser

  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
Constructor Summary
          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


public JaxpSchemaParser()

Create a new JaxpSchemaParser instance.

Method Detail


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:

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

Specified by:
configure in interface Configurable


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

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
source - the Source associated with the Schema to return.
a non-null Schema instance.
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.


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
a non-null array of Strings.

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