org.apache.cocoon.transformation
Class ValidatingTransformer

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.xml.AbstractXMLPipe
              extended by org.apache.cocoon.transformation.AbstractTransformer
                  extended by org.apache.cocoon.transformation.ValidatingTransformer
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, Configurable, LogEnabled, Serviceable, CacheableProcessingComponent, SitemapModelComponent, Transformer, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class ValidatingTransformer
extends AbstractTransformer
implements Configurable, Serviceable, Disposable, CacheableProcessingComponent

The ValidatingTransformer provides a very simple Transformer validating documents while being processed in a Cocoon pipeline.

The only defined (but not required) configuration for this component is <grammar>...string...</grammar> indicating the default grammar language of the schemas to use.

This configuration parameter can be overridden by specifying the grammar parameter when using this Transformer in a pipeline.

If no grammar is specified (either as a configuration, or a parameter) this transformer will instruct the Validator to try and guess the grammar of the schema being parsed.


Field Summary
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
ValidatingTransformer()
          Create a new ValidatingTransformer instance.
 
Method Summary
 void configure(Configuration configuration)
          Configure this component instance.
 void dispose()
          Dispose of this component instance releasing all previously acquired required instances back to the ServiceManager.
 Serializable getKey()
          Return the unique key to associated with the schema being processed in the scope of the request being processed for caching.
 SourceValidity getValidity()
          Return the SourceValidity associated with the schema currently being processed in the scope of the request being processed.
 void recycle()
          Recycle this component instance at the end of request processing.
 void service(ServiceManager manager)
          Contextualize this component instance specifying its associated ServiceManager instance.
 void setConsumer(XMLConsumer consumer)
          Specify the XMLConsumer receiving SAX events emitted by this Transformer instance in the scope of a request.
 void setup(SourceResolver resolver, Map objectModel, String source, Parameters parameters)
          Contextualize this component in the scope of a pipeline when a request is processed.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 

Constructor Detail

ValidatingTransformer

public ValidatingTransformer()

Create a new ValidatingTransformer instance.

Method Detail

service

public void service(ServiceManager manager)
             throws ServiceException

Contextualize this component instance specifying its associated ServiceManager instance.

Specified by:
service in interface Serviceable
Parameters:
manager - the ServiceManager to associate with this component.
Throws:
ServiceException - if a dependancy of this could not be resolved.

configure

public void configure(Configuration configuration)
               throws ConfigurationException

Configure this component instance.

The only defined (but not required) configuration for this component is <grammar>...string...</grammar> indicating the default grammar used by this transformer used for parsing schemas.

Specified by:
configure in interface Configurable
Parameters:
configuration - a Configuration instance for this component.
Throws:
ConfigurationException - never thrown.

dispose

public void dispose()

Dispose of this component instance releasing all previously acquired required instances back to the ServiceManager.

Specified by:
dispose in interface Disposable

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String source,
                  Parameters parameters)
           throws ProcessingException,
                  SAXException,
                  IOException

Contextualize this component in the scope of a pipeline when a request is processed.

Specified by:
setup in interface SitemapModelComponent
Parameters:
resolver - the SourceResolver contextualized in this request.
objectModel - unused.
source - the source URI of the schema to validate against.
parameters - unused.
Throws:
ProcessingException
SAXException
IOException

setConsumer

public void setConsumer(XMLConsumer consumer)

Specify the XMLConsumer receiving SAX events emitted by this Transformer instance in the scope of a request.

Specified by:
setConsumer in interface XMLProducer
Overrides:
setConsumer in class AbstractXMLProducer
Parameters:
consumer - the XMLConsumer to send SAX events to.

getKey

public Serializable getKey()

Return the unique key to associated with the schema being processed in the scope of the request being processed for caching.

Specified by:
getKey in interface CacheableProcessingComponent
Returns:
a non null String representing the unique key for the schema.

getValidity

public SourceValidity getValidity()

Return the SourceValidity associated with the schema currently being processed in the scope of the request being processed.

Specified by:
getValidity in interface CacheableProcessingComponent
Returns:
a non null SourceValidity instance.

recycle

public void recycle()

Recycle this component instance at the end of request processing.

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class AbstractXMLProducer


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