org.apache.cocoon.transformation
Class ValidationReportTransformer

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.ValidationReportTransformer
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, Configurable, LogEnabled, Serviceable, CacheableProcessingComponent, SitemapModelComponent, Transformer, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

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

The ValidationReportTransformer provides a Transformer validating documents while being processed in a Cocoon pipeline, and preparing a report of all detected inconsistancies according the specified schema.

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.

The report prepared by this transformer will look like the following:

   <report xmlns="http://apache.org/cocoon/validation/1.0">
     <warning system="..." public="..." line="..." column="...">
       ... detailed message ...
     </warning>
     <error system="..." public="..." line="..." column="...">
       ... detailed message ...
     </error>
     <fatal system="..." public="..." line="..." column="...">
       ... message ...
     </fatal>
   </report>
 

The location attributes specified in the <warning/>, <error/> and <fatal/> tags are all optional and will be generated only if known.


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
ValidationReportTransformer()
          Create a new ValidationReportTransformer 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.
 void endDocument()
          Receive notification of the end of the document and produce the report of the validation result.
 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, 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, 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

ValidationReportTransformer

public ValidationReportTransformer()

Create a new ValidationReportTransformer 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.

endDocument

public void endDocument()
                 throws SAXException

Receive notification of the end of the document and produce the report of the validation result.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class AbstractXMLPipe
Throws:
SAXException
See Also:
ContentHandler.endDocument()

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.