| org.apache.cocoon.transformation.AbstractTransformer org.apache.cocoon.transformation.AbstractSAXTransformer
All known Subclasses: org.apache.cocoon.transformation.SQLTransformer, org.apache.cocoon.portal.tools.transformation.CheckAccessTransformer, org.apache.cocoon.portal.tools.transformation.PortalToolsLayoutTransformer, org.apache.cocoon.transformation.VariableRewriterTransformer, org.apache.lenya.cms.cocoon.transformation.UsecaseMenuTransformer, org.apache.lenya.cms.cocoon.transformation.AccessControlSitetreeTransformer, org.apache.cocoon.transformation.UuidToUrlTransformer, org.apache.cocoon.transformation.LinkRewriterTransformer, org.apache.cocoon.portal.transformation.AbstractCopletTransformer, org.apache.cocoon.transformation.SourceWritingTransformer, org.apache.lenya.cms.cocoon.transformation.AbstractLinkTransformer, org.apache.cocoon.webapps.session.transformation.AbstractSessionTransformer, org.apache.cocoon.mail.transformation.SendMailTransformer, org.apache.cocoon.transformation.CleanupTransformer, org.apache.cocoon.transformation.TeeTransformer, org.apache.cocoon.transformation.DASLTransformer, org.apache.cocoon.portal.coplets.basket.AbstractBasketTransformer, org.apache.cocoon.transformation.NekoHTMLTransformer, org.apache.lenya.cms.cocoon.transformation.WorkflowMenuTransformer, org.apache.cocoon.transformation.SimpleFormTransformer, org.apache.cocoon.transformation.CIncludeTransformer, org.apache.lenya.cms.cocoon.transformation.MetaDataTransformer, org.apache.cocoon.transformation.HTMLTransformer, org.apache.cocoon.transformation.JPathTransformer, org.apache.cocoon.portal.transformation.RSSTransformer, org.apache.cocoon.transformation.SourcePropsWritingTransformer, org.apache.cocoon.transformation.WebDAVTransformer,
AbstractSAXTransformer | abstract public class AbstractSAXTransformer extends AbstractTransformer implements Serviceable,Configurable,Disposable(Code) | | This class is the basis for all transformers. It provides various useful
methods and hooks for implementing own custom transformers.
The basic behaviour of each transformer consists of the following four
parts:
- Listen for specific events with a given namespace
- Collect information via these events
- Process the information
- Create new events from the processed information
For all these four purposes the AbstractSAXTransformer offers some
powerful methods and hooks:
Namespace handling
By setting the instance variable namespaceURI to the namespace the
events are filtered and only events with this namespace are send to
the two hooks: startTransformingElement and
endTransformingElement . It is possible to override the default
namespace for the transformer by specifying the parameter "namespaceURI"
in the pipeline. This avoids possible namespace collisions.
Recording of information
There are several methods for recording information, e.g. startRecording(),
startTextRecording() etc. These methods collect information from the xml
stream for further processing.
Creating new events
New events can be easily created with the sendEvents()
method, the sendStartElementEvent() methods, the
sendEndElementEvent() method or the
sendTextEvent() method.
Initialization
Before the document is processed the setupTransforming hook
is invoked.
author: Carsten Ziegeler version: $Id: AbstractSAXTransformer.java 433543 2006-08-22 06:22:54Z crossley $ |
Method Summary | |
protected void | addRecorder(XMLConsumer recorder) Add a new recorder to the recording chain. | public void | characters(char[] p0, int p1, int p2) Process the SAX event. | public void | comment(char ary, int start, int length) | public void | configure(Configuration configuration) | public void | dispose() | public void | endCDATA() | public void | endDTD() | public void | endDocument() Process the SAX event. | public void | endElement(String uri, String name, String raw) Process the SAX event. | public void | endEntity(String name) | public SourceParameters | endParametersRecording(Parameters source) End recording of parameters
If source is null a new parameters object is created, otherwise
the parameters are added to this object.
Parameters: source - An optional parameters object. | public SourceParameters | endParametersRecording(SourceParameters source) End recording of parameters
If source is null a new parameters object is created, otherwise
the parameters are added to this object.
Parameters: source - An optional parameters object. | public void | endPrefixMapping(String prefix) Process the SAX event. | public DocumentFragment | endRecording() Stop DOM DocumentFragment recording. | public XMLizable | endSAXRecording() Stop recording of SAX events. | public String | endSerializedXMLRecording() Return the serialized xml string. | public String | endTextRecording() Stop recording of text and return the recorded information. | public void | endTransformingElement(String uri, String name, String raw) Start processing elements of our namespace. | protected String | findPrefixMapping(String uri) Find prefix mapping for the given namespace URI. | protected AttributesImpl | getMutableAttributes(Attributes a) Helper method to get a modifiable attribute set. | public void | ignorableWhitespace(char[] p0, int p1, int p2) Process the SAX event. | public void | processingInstruction(String target, String data) Process the SAX event. | public void | recycle() | protected Object | removeRecorder() Remove a recorder from the recording chain. | public void | sendEndElementEvent(String localname) Send SAX events to the next pipeline component. | public void | sendEndElementEventNS(String localname) Send SAX events to the next pipeline component. | protected void | sendEndPrefixMapping() | public void | sendEvents(Node node) Send SAX events to the next pipeline component. | public void | sendParametersEvents(SourceParameters pars) Send SAX events for the SourceParameters . | public void | sendStartElementEvent(String localname) Send SAX events to the next pipeline component. | public void | sendStartElementEvent(String localname, Attributes attr) Send SAX events to the next pipeline component. | public void | sendStartElementEventNS(String localname) Send SAX events to the next pipeline component. | public void | sendStartElementEventNS(String localname, Attributes attr) Send SAX events to the next pipeline component. | protected void | sendStartPrefixMapping() | public void | sendTextEvent(String text) Send SAX events to the next pipeline component. | public void | service(ServiceManager manager) | public void | setDocumentLocator(Locator locator) Process the SAX event. | public void | setup(SourceResolver resolver, Map objectModel, String src, Parameters params) | public void | setupTransforming() Setup the transformation of an xml document.
This method is called just before the transformation (sending of sax events)
starts. | public void | skippedEntity(String name) Process the SAX event. | public void | startCDATA() | public void | startDTD(String name, String public_id, String system_id) | public void | startDocument() Process the SAX event. | public void | startElement(String uri, String name, String raw, Attributes attr) Process the SAX event. | public void | startEntity(String name) | public void | startParametersRecording() Start recording of parameters.
All events are not forwarded and the incoming xml is converted to
parameters. | public void | startPrefixMapping(String prefix, String uri) Process the SAX event. | public void | startRecording() Start DOM DocumentFragment recording.
All incoming events are recorded and not forwarded. | public void | startSAXRecording() Start recording of SAX events.
All incoming events are recorded and not forwarded. | public void | startSerializedXMLRecording(Properties format) Start recording of serialized xml
All events are converted to an xml string which can be retrieved by
endSerializedXMLRecording.
Parameters: format - The format for the serialized output. | public void | startTextRecording() Start recording of a text. | public void | startTransformingElement(String uri, String name, String raw, Attributes attr) Start processing elements of our namespace. |
EMPTY_ATTRIBUTES | final protected static Attributes EMPTY_ATTRIBUTES(Code) | | Empty immutable attributes (for performance). Use them
whenever creating an element with no attributes.
|
context | protected Context context(Code) | | The current Context object
|
defaultNamespaceURI | protected String defaultNamespaceURI(Code) | | This is the default namespace used by the transformer.
Implementations should set its value in the constructor.
Must never be null.
|
ignoreEmptyCharacters | protected boolean ignoreEmptyCharacters(Code) | | Controlls SAX event handling.
If set to true all characters events containing only whitespaces
are ignored.
|
ignoreEventsCount | protected int ignoreEventsCount(Code) | | Controlls SAX event handling.
If this is incremented all events are not forwarded to the next
pipeline component, but the hooks are still called.
|
ignoreHooksCount | protected int ignoreHooksCount(Code) | | Controlls SAX event handling.
If this is greater than zero, the hooks are not called. Attention,
make sure, that you decrement this counter properly as your hooks are
not called anymore!
|
ignoreWhitespaces | protected boolean ignoreWhitespaces(Code) | | Controlls SAX event handling.
If set to true all whitespace events are ignored.
|
manager | protected ServiceManager manager(Code) | | The Avalon ServiceManager for getting Components
|
namespaceURI | protected String namespaceURI(Code) | | The namespace used by the transformer for the SAX events filtering.
This either equals to the
AbstractSAXTransformer.defaultNamespaceURI or to the value
set by the namespaceURI sitemap parameter for the pipeline.
Must never be null.
|
objectModel | protected Map objectModel(Code) | | The current objectModel of the environment
|
parameters | protected Parameters parameters(Code) | | The parameters specified in the sitemap
|
recorderStack | final protected Stack recorderStack(Code) | | The stack of current used recorders
|
request | protected Request request(Code) | | The current Request object
|
source | protected String source(Code) | | The source attribute specified in the sitemap
|
stack | final protected Stack stack(Code) | | A stack for collecting information.
The stack is important for collection information especially when
the tags can be nested.
|
addRecorder | protected void addRecorder(XMLConsumer recorder)(Code) | | Add a new recorder to the recording chain.
Do not invoke this method directly.
|
configure | public void configure(Configuration configuration) throws ConfigurationException(Code) | | |
dispose | public void dispose()(Code) | | |
endParametersRecording | public SourceParameters endParametersRecording(Parameters source) throws SAXException(Code) | | End recording of parameters
If source is null a new parameters object is created, otherwise
the parameters are added to this object.
Parameters: source - An optional parameters object. The object containing all parameters. |
endParametersRecording | public SourceParameters endParametersRecording(SourceParameters source) throws SAXException(Code) | | End recording of parameters
If source is null a new parameters object is created, otherwise
the parameters are added to this object.
Parameters: source - An optional parameters object. The object containing all parameters. |
endRecording | public DocumentFragment endRecording() throws SAXException(Code) | | Stop DOM DocumentFragment recording.
This method returns the resulting DocumentFragment, normalized.
|
endSAXRecording | public XMLizable endSAXRecording() throws SAXException(Code) | | Stop recording of SAX events.
This method returns the resulting XMLizable.
since: 2.1.5 |
endSerializedXMLRecording | public String endSerializedXMLRecording() throws SAXException, ProcessingException(Code) | | Return the serialized xml string.
A string containing the recorded xml information, formatted bythe properties passed to the corresponding startSerializedXMLRecording(). |
endTextRecording | public String endTextRecording() throws SAXException(Code) | | Stop recording of text and return the recorded information.
The String, trimmed. |
endTransformingElement | public void endTransformingElement(String uri, String name, String raw) throws ProcessingException, IOException, SAXException(Code) | | Start processing elements of our namespace.
This hook is invoked for each sax event with our namespace.
Parameters: uri - The namespace of the element. Parameters: name - The local name of the element. Parameters: raw - The qualified name of the element. |
findPrefixMapping | protected String findPrefixMapping(String uri)(Code) | | Find prefix mapping for the given namespace URI.
Prefix mapping or null if no prefix defined |
recycle | public void recycle()(Code) | | |
removeRecorder | protected Object removeRecorder()(Code) | | Remove a recorder from the recording chain.
Do not invoke this method directly.
|
sendEndElementEvent | public void sendEndElementEvent(String localname) throws SAXException(Code) | | Send SAX events to the next pipeline component.
The endElement event for the given element is send
to the next component in the current pipeline.
The element has no namespace.
Parameters: localname - The name of the event. |
sendEndElementEventNS | public void sendEndElementEventNS(String localname) throws SAXException(Code) | | Send SAX events to the next pipeline component.
The endElement event for the given element is send
to the next component in the current pipeline.
The element has the namespace of the transformer.
Parameters: localname - The name of the event. |
sendEndPrefixMapping | protected void sendEndPrefixMapping() throws SAXException(Code) | | Send all end prefix mapping events to the current content handler
|
sendEvents | public void sendEvents(Node node) throws SAXException(Code) | | Send SAX events to the next pipeline component.
The node is parsed and the events are send to
the next component in the pipeline.
Parameters: node - The tree to be included. |
sendParametersEvents | public void sendParametersEvents(SourceParameters pars) throws SAXException(Code) | | Send SAX events for the SourceParameters .
For each parametername/value pair an element is
created with the name of the parameter and the content
of this element is the value.
|
sendStartElementEvent | public void sendStartElementEvent(String localname) throws SAXException(Code) | | Send SAX events to the next pipeline component.
The startElement event for the given element is send
to the next component in the current pipeline.
The element has no namespace and no attributes
Parameters: localname - The name of the event. |
sendStartElementEvent | public void sendStartElementEvent(String localname, Attributes attr) throws SAXException(Code) | | Send SAX events to the next pipeline component.
The startElement event for the given element is send
to the next component in the current pipeline.
The element has no namespace.
Parameters: localname - The name of the event. Parameters: attr - The Attributes of the element |
sendStartElementEventNS | public void sendStartElementEventNS(String localname) throws SAXException(Code) | | Send SAX events to the next pipeline component.
The startElement event for the given element is send
to the next component in the current pipeline.
The element has the namespace of the transformer,
but not attributes
Parameters: localname - The name of the event. |
sendStartElementEventNS | public void sendStartElementEventNS(String localname, Attributes attr) throws SAXException(Code) | | Send SAX events to the next pipeline component.
The startElement event for the given element is send
to the next component in the current pipeline.
The element has the namespace of the transformer.
Parameters: localname - The name of the event. Parameters: attr - The Attributes of the element |
sendStartPrefixMapping | protected void sendStartPrefixMapping() throws SAXException(Code) | | Send all start prefix mapping events to the current content handler
|
sendTextEvent | public void sendTextEvent(String text) throws SAXException(Code) | | Send SAX events to the next pipeline component.
The characters event for the given text is send to the next
component in the current pipeline.
Parameters: text - The string containing the information. |
service | public void service(ServiceManager manager) throws ServiceException(Code) | | |
setupTransforming | public void setupTransforming() throws IOException, ProcessingException, SAXException(Code) | | Setup the transformation of an xml document.
This method is called just before the transformation (sending of sax events)
starts. It should be used to initialize setup parameter depending on the
object modell.
|
startParametersRecording | public void startParametersRecording() throws SAXException(Code) | | Start recording of parameters.
All events are not forwarded and the incoming xml is converted to
parameters. Each toplevel node is a parameter and its text subnodes
form the value.
The Parameters can eiter be retrieved by endParametersRecording().
|
startSerializedXMLRecording | public void startSerializedXMLRecording(Properties format) throws SAXException(Code) | | Start recording of serialized xml
All events are converted to an xml string which can be retrieved by
endSerializedXMLRecording.
Parameters: format - The format for the serialized output. If null is specified, the default format is used. |
startTextRecording | public void startTextRecording() throws SAXException(Code) | | Start recording of a text.
No events forwarded, and all characters events
are collected into a string.
|
startTransformingElement | public void startTransformingElement(String uri, String name, String raw, Attributes attr) throws ProcessingException, IOException, SAXException(Code) | | Start processing elements of our namespace.
This hook is invoked for each sax event with our namespace.
Parameters: uri - The namespace of the element. Parameters: name - The local name of the element. Parameters: raw - The qualified name of the element. Parameters: attr - The attributes of the element. |
|
|