Save This Page
Home » cocoon-2.1.11-src » org.apache » cocoon » sunshine » transformation » [javadoc | source]
org.apache.cocoon.sunshine.transformation
public class: InsertTransformer [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.sunshine.transformation.AbstractSunShineTransformer
                     org.apache.cocoon.sunshine.transformation.InsertTransformer

All Implemented Interfaces:
    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

This implementation allows the inserting of an xml fragment into a resource which is configured in sunConfig. XPath denoting the position to insert the xml fragment By default, the fragment is always inserted (added). It is possible to specify a node (by an XPath) which will be replaced if it exists. XPath denoting the position to insert the xml fragment XPath denoting a criteria for which node will be replaced The information for replace has to be relative to path, but can specify a subnode of the node the be replaced. The XPath specification is very complicated. So here is an example for the sitemap: /*[namespace-uri()="http://apache.org/cocoon/sitemap/1.0" and local-name()="sitemap"]/*[namespace-uri()="http://apache.org/cocoon/sitemap/1.0" and local-name()="components"]/*[namespace-uri()="http://apache.org/cocoon/sitemap/1.0" and local-name()="generators"] *[namespace-uri()="http://apache.org/cocoon/sitemap/1.0" and local-name()="generator" and attribute::name="file"] This insert replace (if it exists) the file generator definition with a new one. As the sitemap uses namespaces the XPath for the generator is rather complicated. Due to this it is necessary that the node specified by path exists if namespaces are used! Otherwise a node with the name * would be created... The create attribute of insert. If this is set to true (default is true), the file is created if it does not exists. If it is set to false, it is not created, making insert a real insert. create is only usable for files! In addition the overwrite attribute is used to check if replacing is allowed. If overwrite is true (the default) the node is replaced. If it is false the node is not inserted if the replace node is available. The option can be used to reinsert a replaced node at a given path in the new fragment.
Field Summary
public static final  String INSERT_ELEMENT    Elements 
public static final  String INSERT_CREATE_ATTRIBUTE     
public static final  String INSERT_OVERWRITE_ATTRIBUTE     
public static final  String PATH_ELEMENT     
public static final  String FRAGMENT_ELEMENT     
public static final  String REPLACE_ELEMENT     
public static final  String FILE_ELEMENT     
public static final  String REINSERT_ELEMENT     
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
Constructor:
 public InsertTransformer() 
Method from org.apache.cocoon.sunshine.transformation.InsertTransformer Summary:
endTransformingElement,   insertFragment,   setupTransforming,   startTransformingElement
Methods from org.apache.cocoon.sunshine.transformation.AbstractSunShineTransformer:
getResourceConnector,   getSession,   getSunShineComponent,   recycle
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.sunshine.transformation.InsertTransformer Detail:
 public  void endTransformingElement(String uri,
    String name,
    String raw) throws IOException, SAXException, ProcessingException 
 public  void insertFragment(String fileName,
    String path,
    DocumentFragment fragment,
    String replacePath,
    boolean create,
    boolean overwrite,
    String reinsertPath) throws IOException, SAXException, ProcessingException 
    Insert a fragment into a file. The file is loaded by the resource connector.
 public  void setupTransforming() throws IOException, SAXException, ProcessingException 
 public  void startTransformingElement(String uri,
    String name,
    String raw,
    Attributes attr) throws IOException, SAXException, ProcessingException 
    This is the real implementation of the startElement event for the Insert Transformer The event is checked for a valid element and the corresponding command is executed.