|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.xml.AbstractXMLProducer
org.apache.cocoon.xml.AbstractXMLPipe
org.apache.cocoon.transformation.AbstractTransformer
org.apache.cocoon.transformation.CastorTransformer
Castor transformer marshals a object from the Sitemap, Session, Request or the Conext into a series of SAX events.
The CastorTransformer needs to be configured with a default mapping. This mapping is used as long as no other mapping is specified as the element.
<map:transformer name="CastorTransformer" src="org.apache.cocoon.transformation.CastorTransformer"> <mapping>castor/xmapping.xml</mapping> </map:transformer>
Sample usage:
<root xmlns:castor="http://apache.org/cocoon/castor/1.0"> <castor:marshal name="invoice"/> <castor:unmarshal name="product" scope="sitemap" mapping="castor/specicalmapping.xml"/> </root>
The CastorTransfomer supports two elements
castor:unmarshal
and castor:marshal
.
The marshal element is replaced with the marshaled object.
The Object given through the attrbute name
will be searched in the sitemap, request, session
and at
least in application
If the scope is explicitly given, e.g ,
the object will ge located only here. The Attribute mapping
specifys the mapping to be used. The attribute command
specifies a class that
implements CastorMarshalCommand and will be called before and after marshaling.
The elements within the unmarshal element will be sent to the castor unmarshaller
the resulting java object with be placed in the object specified by name and scope (see also marshal element).
The command
attribute specifies the class that implements CastorUnmarshalCommand
and will be called before and after unmarshaling.
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 | |
CastorTransformer()
|
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 params)
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 |
public CastorTransformer()
Method Detail |
public void configure(Configuration conf) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters params) throws ProcessingException, SAXException, IOException
SitemapModelComponent
ObjectModelHelper
for help with the objectModel
.
setup
in interface SitemapModelComponent
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.params
- The sitemap parameters passed into your component.
ProcessingException
- if there is any other unexpected problem.
IOException
- if there is a problem reading files.
SAXException
- if there is a problem reading a SAX stream.public void recycle()
AbstractXMLProducer
recycle
in interface Recyclable
recycle
in class AbstractXMLProducer
public void endElement(String uri, String name, String raw) throws SAXException
AbstractXMLPipe
endElement
in interface ContentHandler
endElement
in class AbstractXMLPipe
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.
SAXException
public void startElement(String uri, String name, String raw, Attributes attr) throws SAXException
AbstractXMLPipe
startElement
in interface ContentHandler
startElement
in class AbstractXMLPipe
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.
SAXException
public void characters(char[] ch, int start, int len) throws SAXException
AbstractXMLPipe
characters
in interface ContentHandler
characters
in class AbstractXMLPipe
ch
- The characters from the XML document.start
- The start position in the array.len
- The number of characters to read from the array.
SAXException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |