org.apache.cocoon.transformation
Class SourceWritingTransformer

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.AbstractSAXTransformer
                      extended by org.apache.cocoon.transformation.SourceWritingTransformer
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, Configurable, LogEnabled, Serviceable, SitemapModelComponent, Transformer, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class SourceWritingTransformer
extends AbstractSAXTransformer

Version:
$Id: SourceWritingTransformer.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Carsten Ziegeler, Jeremy Quinn, Gianugo Rabellino

Field Summary
static String ACTION_DELETE
           
static String ACTION_ELEMENT
           
static String ACTION_NEW
           
static String ACTION_NONE
           
static String ACTION_OVER
           
static String BEHAVIOUR_ELEMENT
           
protected  String configuredSerializerName
          The configured serializer name
static String CREATE_ATTRIBUTE
           
static String DEFAULT_SERIALIZER
           
static String DELETE_ELEMENT
           
static String EXECUTION_ELEMENT
           
static String FRAGMENT_ELEMENT
           
static String INSERT_ELEMENT
           
static String MESSAGE_ELEMENT
           
static String OVERWRITE_ATTRIBUTE
           
static String PATH_ELEMENT
           
static String REINSERT_ELEMENT
           
static String REPLACE_ELEMENT
           
static String RESULT_ELEMENT
          outgoing elements
static String RESULT_FAILED
          results
static String RESULT_SUCCESS
           
static String SERIALIZER_ATTRIBUTE
          main (write or insert) tag attributes
static String SERIALIZER_ELEMENT
           
static String SOURCE_ELEMENT
           
static String SWT_URI
           
static String WRITE_ELEMENT
          incoming elements
protected  XPathProcessor xpathProcessor
          The XPath processor
 
Fields inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
context, defaultNamespaceURI, EMPTY_ATTRIBUTES, emptyAttributes, ignoreEmptyCharacters, ignoreEventsCount, ignoreHooksCount, ignoreWhitespaces, manager, namespaceURI, objectModel, parameters, recorderStack, request, resolver, response, source, stack
 
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
SourceWritingTransformer()
          Constructor.
 
Method Summary
 void configure(Configuration configuration)
          Get the current Configuration instance used by this Configurable.
 void dispose()
           
 void endTransformingElement(String uri, String name, String raw)
          Receive notification of the end of an element.
protected  void insertFragment(String systemID, String path, DocumentFragment fragment, String replacePath, boolean create, boolean overwrite, String reinsertPath, String localSerializer, String tagname)
          Insert a fragment into a file.
 void service(ServiceManager manager)
           
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Get the Parameter called "serializer" from the Transformer invocation.
 void startTransformingElement(String uri, String name, String raw, Attributes attr)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
addRecorder, characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endParametersRecording, endParametersRecording, endPrefixMapping, endRecording, endSAXRecording, endSerializedXMLRecording, endTextRecording, findPrefixMapping, getMutableAttributes, ignorableWhitespace, processingInstruction, recycle, removeRecorder, sendEndElementEvent, sendEndElementEventNS, sendEndPrefixMapping, sendEvents, sendParametersEvents, sendStartElementEvent, sendStartElementEvent, sendStartElementEventNS, sendStartElementEventNS, sendStartPrefixMapping, sendTextEvent, setDocumentLocator, setupTransforming, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startParametersRecording, startPrefixMapping, startRecording, startSAXRecording, startSerializedXMLRecording, startTextRecording
 
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.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

SWT_URI

public static final String SWT_URI
See Also:
Constant Field Values

DEFAULT_SERIALIZER

public static final String DEFAULT_SERIALIZER
See Also:
Constant Field Values

WRITE_ELEMENT

public static final String WRITE_ELEMENT
incoming elements

See Also:
Constant Field Values

INSERT_ELEMENT

public static final String INSERT_ELEMENT
See Also:
Constant Field Values

PATH_ELEMENT

public static final String PATH_ELEMENT
See Also:
Constant Field Values

FRAGMENT_ELEMENT

public static final String FRAGMENT_ELEMENT
See Also:
Constant Field Values

REPLACE_ELEMENT

public static final String REPLACE_ELEMENT
See Also:
Constant Field Values

DELETE_ELEMENT

public static final String DELETE_ELEMENT
See Also:
Constant Field Values

SOURCE_ELEMENT

public static final String SOURCE_ELEMENT
See Also:
Constant Field Values

REINSERT_ELEMENT

public static final String REINSERT_ELEMENT
See Also:
Constant Field Values

RESULT_ELEMENT

public static final String RESULT_ELEMENT
outgoing elements

See Also:
Constant Field Values

EXECUTION_ELEMENT

public static final String EXECUTION_ELEMENT
See Also:
Constant Field Values

BEHAVIOUR_ELEMENT

public static final String BEHAVIOUR_ELEMENT
See Also:
Constant Field Values

ACTION_ELEMENT

public static final String ACTION_ELEMENT
See Also:
Constant Field Values

MESSAGE_ELEMENT

public static final String MESSAGE_ELEMENT
See Also:
Constant Field Values

SERIALIZER_ELEMENT

public static final String SERIALIZER_ELEMENT
See Also:
Constant Field Values

SERIALIZER_ATTRIBUTE

public static final String SERIALIZER_ATTRIBUTE
main (write or insert) tag attributes

See Also:
Constant Field Values

CREATE_ATTRIBUTE

public static final String CREATE_ATTRIBUTE
See Also:
Constant Field Values

OVERWRITE_ATTRIBUTE

public static final String OVERWRITE_ATTRIBUTE
See Also:
Constant Field Values

RESULT_FAILED

public static final String RESULT_FAILED
results

See Also:
Constant Field Values

RESULT_SUCCESS

public static final String RESULT_SUCCESS
See Also:
Constant Field Values

ACTION_NONE

public static final String ACTION_NONE
See Also:
Constant Field Values

ACTION_NEW

public static final String ACTION_NEW
See Also:
Constant Field Values

ACTION_OVER

public static final String ACTION_OVER
See Also:
Constant Field Values

ACTION_DELETE

public static final String ACTION_DELETE
See Also:
Constant Field Values

configuredSerializerName

protected String configuredSerializerName
The configured serializer name


xpathProcessor

protected XPathProcessor xpathProcessor
The XPath processor

Constructor Detail

SourceWritingTransformer

public SourceWritingTransformer()
Constructor. Set the namespace.

Method Detail

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Get the current Configuration instance used by this Configurable.

Specified by:
configure in interface Configurable
Overrides:
configure in class AbstractSAXTransformer
Throws:
ConfigurationException

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws ProcessingException,
                  SAXException,
                  IOException
Get the Parameter called "serializer" from the Transformer invocation.

Specified by:
setup in interface SitemapModelComponent
Overrides:
setup in class AbstractSAXTransformer
Throws:
ProcessingException
SAXException
IOException

startTransformingElement

public void startTransformingElement(String uri,
                                     String name,
                                     String raw,
                                     Attributes attr)
                              throws SAXException,
                                     IOException,
                                     ProcessingException
Receive notification of the beginning of an element.

Overrides:
startTransformingElement in class AbstractSAXTransformer
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
IOException
ProcessingException

endTransformingElement

public void endTransformingElement(String uri,
                                   String name,
                                   String raw)
                            throws SAXException,
                                   IOException,
                                   ProcessingException
Receive notification of the end of an element.

Overrides:
endTransformingElement in class AbstractSAXTransformer
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
IOException
ProcessingException

insertFragment

protected void insertFragment(String systemID,
                              String path,
                              DocumentFragment fragment,
                              String replacePath,
                              boolean create,
                              boolean overwrite,
                              String reinsertPath,
                              String localSerializer,
                              String tagname)
                       throws SAXException,
                              IOException,
                              ProcessingException
Insert a fragment into a file. The file is loaded by the resource connector.

Parameters:
systemID - The name of the xml file.
path - The XPath specifying the node under which the data is inserted
fragment - The data to be inserted.
replacePath - Optional XPath relative to path. This path can specify a node which will be removed if it exists. So insertFragment can be used as a replace utility.
create - If the file does not exists and this is set to false nothing is inserted. If it is set to true the file is created and the data is inserted.
overwrite - If this is set to true the data is only inserted if the node specified by the replacePath does not exists.
reinsertPath - If specified and a node is replaced , all children of this replaced node will be reinserted at the given path.
localSerializer - The serializer used to serialize the XML
tagname - The name of the tag that triggered me 'insert' or 'write'
Throws:
SAXException
IOException
ProcessingException

service

public void service(ServiceManager manager)
             throws ServiceException
Specified by:
service in interface Serviceable
Overrides:
service in class AbstractSAXTransformer
Throws:
ServiceException

dispose

public void dispose()
Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractSAXTransformer


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