org.apache.cocoon.transformation
Class BetwixtTransformer

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.xml.AbstractXMLProducer
          extended byorg.apache.cocoon.xml.AbstractXMLPipe
              extended byorg.apache.cocoon.transformation.AbstractTransformer
                  extended byorg.apache.cocoon.transformation.BetwixtTransformer
All Implemented Interfaces:
Configurable, ContentHandler, LexicalHandler, LogEnabled, Poolable, Recyclable, SitemapModelComponent, Transformer, XMLConsumer, XMLConsumer, XMLPipe, XMLProducer

public class BetwixtTransformer
extends AbstractTransformer
implements Configurable

Betwixt transformer marshals a object from the Sitemap, Session, Request or the Conext into a series of SAX events. Configuation: The betwixt transformer can be configured to not output element reference ids. The default setting is to output reference IDs.

   <map:transformer name="betwixt" src="org.apache.cocoon.transformation.BetwixtTransformer"
     <ref-ids>true</ref-ids>
   </map:transformer>
 
A sample for the use:
   <root xmlns:betwixt="http://apache.org/cocoon/betwixt/1.0">
     <betwixt:include name="invoice" />
     <betwixt:include name="product" scope="sitemap" />
     <betwixt:include name="product2" element="other-product" />
   </root>
 
The BetwixtTransfomer support only one Element betwixt:include. This element is replaced with the marshalled object. The Object given through the attribute name will be searched in the request, session, context and at least in sitemap. If the scope is explicitly given, the object will ge located only there. The attribute element can be given to specify an alternativ root element for the object. Collections are marshalled by marshalling each object it contains.

Author:
Christoph Gaffga
See Also:
Betwixt Projekt Homepage

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
BetwixtTransformer()
           
 
Method Summary
 void characters(char[] ch, int start, int len)
          Receive notification of character data.
 void configure(Configuration conf)
           
 void endElement(String uri, String name, String raw)
          Receive notification of the end of an element.
 void recycle()
          Recycle the producer by removing references, and resetting handlers to null (empty) implementations.
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          The Sitemap will call the setup() method to prepare the component for use.
 void startElement(String uri, String name, String raw, Attributes attr)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, 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
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Constructor Detail

BetwixtTransformer

public BetwixtTransformer()
Method Detail

configure

public void configure(Configuration conf)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
Description copied from interface: SitemapModelComponent
The Sitemap will call the setup() method to prepare the component for use. This is where you start the process of getting your information ready to generate your results. See ObjectModelHelper for help with the objectModel.

Specified by:
setup in interface SitemapModelComponent
Parameters:
resolver - The SourceResolver to find resources within your context.
objectModel - A java.util.Map that contains the request and session information.
src - The value of the "src" attribute in the sitemap.
par - The sitemap parameters passed into your component.

recycle

public void recycle()
Description copied from class: AbstractXMLProducer
Recycle the producer by removing references, and resetting handlers to null (empty) implementations.

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

endElement

public void endElement(String uri,
                       String name,
                       String raw)
                throws SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of an element.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
name - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
Throws:
SAXException

startElement

public void startElement(String uri,
                         String name,
                         String raw,
                         Attributes attr)
                  throws SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the beginning of an element.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
name - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
attr - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int len)
                throws SAXException
Description copied from class: AbstractXMLPipe
Receive notification of character data.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class AbstractXMLPipe
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
len - The number of characters to read from the array.
Throws:
SAXException


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.