Save This Page
Home » cocoon-2.1.11-src » org.apache » cocoon » transformation » [javadoc | source]
org.apache.cocoon.transformation
public class: CleanupTransformer [javadoc | source]
java.lang.Object
   org.apache.avalon.framework.logger.AbstractLogEnabled
      org.apache.cocoon.xml.AbstractXMLProducer
         org.apache.cocoon.xml.AbstractXMLPipe
            org.apache.cocoon.transformation.AbstractTransformer
               org.apache.cocoon.transformation.AbstractSAXTransformer
                  org.apache.cocoon.transformation.CleanupTransformer

All Implemented Interfaces:
    CacheableProcessingComponent, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.configuration.Configurable, Transformer, XMLPipe, org.apache.avalon.excalibur.pool.Recyclable, XMLProducer

Cleanup transformer: Removes excess whitespace while adding some where needed for legibility. Strips unwanted namespace declarations.

The cleanup transformer can be used for basically any document as-is or customized by schema (inline vs. block elements) for easier reading.

Transformer declaration: <map:components> <map:transformers> <map:transformer name="htmlcleanup" src="org.apache.cocoon.transformation.CleanupTransformer"> <preserve-uri>*</preserve-uri> </map:transformer> <map:transformer name="xhtmlcleanup" src="org.apache.cocoon.transformation.CleanupTransformer"> <inline-elements>a,abbr,acronym,b,br,font,i,u,img</inline-elements> <preserve-uri>http://www.w3.org/1999/xhtml</preserve-uri> </map:transformer> </map:transformers> </map:components>

The "inline-elements" configuration element refers to a list of element names that are not to be indented. The "preserve-uri" configuration element specifies a namespace uri mapping that is meant for output. All other namespace declarations are stripped from the output. The "preserve-uri" element may appear more than once. If "preserve-uri" is omitted, all namespaces/prefixes are removed from the output.

Transformer usage: <transform type="xhtmlcleanup"> <map:parameter name="indent-size" value="4"/> </transform>

The optional parameter "indent-size" specifies the number of additional space characters appearing at each level of the output document. The default value is 2.

Bugs: Nested namespace declarations with the same namespace prefix will break the code.

Fields inherited from org.apache.cocoon.transformation.AbstractSAXTransformer:
EMPTY_ATTRIBUTES,  ignoreWhitespaces,  ignoreEmptyCharacters,  ignoreEventsCount,  ignoreHooksCount,  namespaceURI,  defaultNamespaceURI,  stack,  recorderStack,  request,  response,  context,  objectModel,  parameters,  source,  manager,  resolver,  emptyAttributes
Fields inherited from org.apache.cocoon.xml.AbstractXMLProducer:
EMPTY_CONTENT_HANDLER,  xmlConsumer,  contentHandler,  lexicalHandler
Method from org.apache.cocoon.transformation.CleanupTransformer Summary:
characters,   configure,   endElement,   endPrefixMapping,   getKey,   getValidity,   ignorableWhitespace,   recycle,   setup,   startElement,   startPrefixMapping
Methods from org.apache.cocoon.transformation.AbstractSAXTransformer:
addRecorder,   characters,   comment,   configure,   dispose,   endCDATA,   endDTD,   endDocument,   endElement,   endEntity,   endParametersRecording,   endParametersRecording,   endPrefixMapping,   endRecording,   endSAXRecording,   endSerializedXMLRecording,   endTextRecording,   endTransformingElement,   findPrefixMapping,   getMutableAttributes,   ignorableWhitespace,   processingInstruction,   recycle,   removeRecorder,   sendEndElementEvent,   sendEndElementEventNS,   sendEndPrefixMapping,   sendEvents,   sendParametersEvents,   sendStartElementEvent,   sendStartElementEvent,   sendStartElementEventNS,   sendStartElementEventNS,   sendStartPrefixMapping,   sendTextEvent,   service,   setDocumentLocator,   setup,   setupTransforming,   skippedEntity,   startCDATA,   startDTD,   startDocument,   startElement,   startEntity,   startParametersRecording,   startPrefixMapping,   startRecording,   startSAXRecording,   startSerializedXMLRecording,   startTextRecording,   startTransformingElement
Methods from org.apache.cocoon.xml.AbstractXMLPipe:
characters,   comment,   endCDATA,   endDTD,   endDocument,   endElement,   endEntity,   endPrefixMapping,   ignorableWhitespace,   processingInstruction,   setDocumentLocator,   skippedEntity,   startCDATA,   startDTD,   startDocument,   startElement,   startEntity,   startPrefixMapping
Methods from org.apache.cocoon.xml.AbstractXMLProducer:
recycle,   setConsumer,   setContentHandler,   setLexicalHandler
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.cocoon.transformation.CleanupTransformer Detail:
 public  void characters(char[] ch,
    int start,
    int length) throws SAXException 
 public  void configure(Configuration conf) throws ConfigurationException 
 public  void endElement(String uri,
    String qName,
    String lName) throws SAXException 
 public  void endPrefixMapping(String prefix) throws SAXException 
 public Serializable getKey() 
 public SourceValidity getValidity() 
 public  void ignorableWhitespace(char[] ch,
    int start,
    int length) throws SAXException 
 public  void recycle() 
 public  void setup(SourceResolver resolver,
    Map objectModel,
    String src,
    Parameters par) throws IOException, SAXException, ProcessingException 
 public  void startElement(String uri,
    String qName,
    String lName,
    Attributes attrs) throws SAXException 
 public  void startPrefixMapping(String prefix,
    String uri) throws SAXException