|
||||||||||
| 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.AbstractSAXTransformer
public abstract class AbstractSAXTransformer
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:
For all these four purposes the AbstractSAXTransformer offers some powerful methods and 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.
sendEvents()
method, the sendStartElementEvent() methods, the
sendEndElementEvent() method or the
sendTextEvent() method.
setupTransforming hook
is invoked.
| Field Summary | |
|---|---|
protected Context |
context
The current Context object |
protected String |
defaultNamespaceURI
This is the default namespace used by the transformer. |
protected static Attributes |
EMPTY_ATTRIBUTES
Empty immutable attributes (for performance). |
protected Attributes |
emptyAttributes
Deprecated. Use EMPTY_ATTRIBUTES. |
protected boolean |
ignoreEmptyCharacters
Controlls SAX event handling. |
protected int |
ignoreEventsCount
Controlls SAX event handling. |
protected int |
ignoreHooksCount
Controlls SAX event handling. |
protected boolean |
ignoreWhitespaces
Controlls SAX event handling. |
protected ServiceManager |
manager
The Avalon ServiceManager for getting Components |
protected String |
namespaceURI
The namespace used by the transformer for the SAX events filtering. |
protected Map |
objectModel
The current objectModel of the environment |
protected Parameters |
parameters
The parameters specified in the sitemap |
protected Stack |
recorderStack
The stack of current used recorders |
protected Request |
request
The current Request object |
protected SourceResolver |
resolver
The SourceResolver for this request |
protected Response |
response
The current Response object |
protected String |
source
The source attribute specified in the sitemap |
protected Stack |
stack
A stack for collecting information. |
| 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 | |
|---|---|
AbstractSAXTransformer()
|
|
| Method Summary | |
|---|---|
protected void |
addRecorder(XMLConsumer recorder)
Add a new recorder to the recording chain. |
void |
characters(char[] p0,
int p1,
int p2)
Process the SAX event. |
void |
comment(char[] ary,
int start,
int length)
Report an XML comment anywhere in the document. |
void |
configure(Configuration configuration)
|
void |
dispose()
|
void |
endCDATA()
Report the end of a CDATA section. |
void |
endDocument()
Process the SAX event. |
void |
endDTD()
Report the end of DTD declarations. |
void |
endElement(String uri,
String name,
String raw)
Process the SAX event. |
void |
endEntity(String name)
Report the end of an entity. |
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. |
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. |
void |
endPrefixMapping(String prefix)
Process the SAX event. |
DocumentFragment |
endRecording()
Stop DOM DocumentFragment recording. |
XMLizable |
endSAXRecording()
Stop recording of SAX events. |
String |
endSerializedXMLRecording()
Return the serialized xml string. |
String |
endTextRecording()
Stop recording of text and return the recorded information. |
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. |
void |
ignorableWhitespace(char[] p0,
int p1,
int p2)
Process the SAX event. |
void |
processingInstruction(String target,
String data)
Process the SAX event. |
void |
recycle()
Recycle the producer by removing references, and resetting handlers to null (empty) implementations. |
protected Object |
removeRecorder()
Remove a recorder from the recording chain. |
void |
sendEndElementEvent(String localname)
Send SAX events to the next pipeline component. |
void |
sendEndElementEventNS(String localname)
Send SAX events to the next pipeline component. |
protected void |
sendEndPrefixMapping()
Send all end prefix mapping events to the current content handler |
void |
sendEvents(Node node)
Send SAX events to the next pipeline component. |
void |
sendParametersEvents(SourceParameters pars)
Send SAX events for the SourceParameters. |
void |
sendStartElementEvent(String localname)
Send SAX events to the next pipeline component. |
void |
sendStartElementEvent(String localname,
Attributes attr)
Send SAX events to the next pipeline component. |
void |
sendStartElementEventNS(String localname)
Send SAX events to the next pipeline component. |
void |
sendStartElementEventNS(String localname,
Attributes attr)
Send SAX events to the next pipeline component. |
protected void |
sendStartPrefixMapping()
Send all start prefix mapping events to the current content handler |
void |
sendTextEvent(String text)
Send SAX events to the next pipeline component. |
void |
service(ServiceManager manager)
|
void |
setDocumentLocator(Locator locator)
Process the SAX event. |
void |
setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters params)
Set the SourceResolver, objectModel Map,
the source and sitemap Parameters used to process the request. |
void |
setupTransforming()
Setup the transformation of an xml document. |
void |
skippedEntity(String name)
Process the SAX event. |
void |
startCDATA()
Report the start of a CDATA section. |
void |
startDocument()
Process the SAX event. |
void |
startDTD(String name,
String public_id,
String system_id)
Report the start of DTD declarations, if any. |
void |
startElement(String uri,
String name,
String raw,
Attributes attr)
Process the SAX event. |
void |
startEntity(String name)
Report the beginning of an entity. |
void |
startParametersRecording()
Start recording of parameters. |
void |
startPrefixMapping(String prefix,
String uri)
Process the SAX event. |
void |
startRecording()
Start DOM DocumentFragment recording. |
void |
startSAXRecording()
Start recording of SAX events. |
void |
startSerializedXMLRecording(Properties format)
Start recording of serialized xml All events are converted to an xml string which can be retrieved by endSerializedXMLRecording. |
void |
startTextRecording()
Start recording of a text. |
void |
startTransformingElement(String uri,
String name,
String raw,
Attributes attr)
Start processing elements of our namespace. |
| 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 |
|---|
protected static final Attributes EMPTY_ATTRIBUTES
protected boolean ignoreWhitespaces
protected boolean ignoreEmptyCharacters
protected int ignoreEventsCount
protected int ignoreHooksCount
protected String namespaceURI
defaultNamespaceURI or to the value
set by the namespaceURI sitemap parameter for the pipeline.
Must never be null.
protected String defaultNamespaceURI
protected final Stack stack
protected final Stack recorderStack
protected Request request
protected Response response
protected Context context
protected Map objectModel
protected Parameters parameters
protected String source
protected ServiceManager manager
protected SourceResolver resolver
protected Attributes emptyAttributes
EMPTY_ATTRIBUTES.
| Constructor Detail |
|---|
public AbstractSAXTransformer()
| Method Detail |
|---|
public void service(ServiceManager manager)
throws ServiceException
service in interface ServiceableServiceException
public void configure(Configuration configuration)
throws ConfigurationException
configure in interface ConfigurableConfigurationException
public void setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters params)
throws ProcessingException,
SAXException,
IOException
SitemapModelComponentSourceResolver, objectModel Map,
the source and sitemap Parameters used to process the request.
setup in interface SitemapModelComponentProcessingException
SAXException
IOExceptionpublic void recycle()
AbstractXMLProducer
recycle in interface Recyclablerecycle in class AbstractXMLProducerpublic void dispose()
dispose in interface Disposablepublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in class AbstractXMLPipelocator - An object that can return the location of any SAX
document event.ContentHandler.setDocumentLocator(org.xml.sax.Locator)
public void startDocument()
throws SAXException
setupTransforming() is invoked.
startDocument in interface ContentHandlerstartDocument in class AbstractXMLPipeSAXExceptionContentHandler.startDocument()
public void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class AbstractXMLPipeSAXExceptionContentHandler.endDocument()
public void startPrefixMapping(String prefix,
String uri)
throws SAXException
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class AbstractXMLPipeprefix - The Namespace prefix being declared.uri - The Namespace URI the prefix is mapped to.
SAXExceptionContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
public void endPrefixMapping(String prefix)
throws SAXException
endPrefixMapping in interface ContentHandlerendPrefixMapping in class AbstractXMLPipeprefix - The prefix that was being mapping.
SAXExceptionContentHandler.endPrefixMapping(java.lang.String)
public void startElement(String uri,
String name,
String raw,
Attributes attr)
throws SAXException
startTransformingElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) hook is called.
startElement in interface ContentHandlerstartElement in class AbstractXMLPipeuri - 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.
SAXExceptionContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endElement(String uri,
String name,
String raw)
throws SAXException
endTransformingElement(java.lang.String, java.lang.String, java.lang.String) hook is called.
endElement in interface ContentHandlerendElement in class AbstractXMLPipeuri - 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.
SAXExceptionContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void characters(char[] p0,
int p1,
int p2)
throws SAXException
characters in interface ContentHandlercharacters in class AbstractXMLPipep0 - The characters from the XML document.p1 - The start position in the array.p2 - The number of characters to read from the array.
SAXExceptionContentHandler.characters(char[], int, int)
public void ignorableWhitespace(char[] p0,
int p1,
int p2)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class AbstractXMLPipep0 - The characters from the XML document.p1 - The start position in the array.p2 - The number of characters to read from the array.
SAXExceptionContentHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(String target,
String data)
throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class AbstractXMLPipetarget - The processing instruction target.data - The processing instruction data, or null if none was
supplied.
SAXExceptionContentHandler.processingInstruction(java.lang.String, java.lang.String)
public void skippedEntity(String name)
throws SAXException
skippedEntity in interface ContentHandlerskippedEntity in class AbstractXMLPipename - The name of the skipped entity. If it is a parameter
entity, the name will begin with '%'.
SAXExceptionContentHandler.skippedEntity(java.lang.String)
public void startDTD(String name,
String public_id,
String system_id)
throws SAXException
AbstractXMLPipe
startDTD in interface LexicalHandlerstartDTD in class AbstractXMLPipename - The document type name.public_id - The declared public identifier for the external DTD
subset, or null if none was declared.system_id - The declared system identifier for the external DTD
subset, or null if none was declared.
SAXExceptionLexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)
public void endDTD()
throws SAXException
AbstractXMLPipe
endDTD in interface LexicalHandlerendDTD in class AbstractXMLPipeSAXExceptionLexicalHandler.endDTD()
public void startEntity(String name)
throws SAXException
AbstractXMLPipe
startEntity in interface LexicalHandlerstartEntity in class AbstractXMLPipename - The name of the entity. If it is a parameter entity, the
name will begin with '%'.
SAXExceptionLexicalHandler.startEntity(java.lang.String)
public void endEntity(String name)
throws SAXException
AbstractXMLPipe
endEntity in interface LexicalHandlerendEntity in class AbstractXMLPipename - The name of the entity that is ending.
SAXExceptionLexicalHandler.endEntity(java.lang.String)
public void startCDATA()
throws SAXException
AbstractXMLPipe
startCDATA in interface LexicalHandlerstartCDATA in class AbstractXMLPipeSAXExceptionLexicalHandler.startCDATA()
public void endCDATA()
throws SAXException
AbstractXMLPipe
endCDATA in interface LexicalHandlerendCDATA in class AbstractXMLPipeSAXExceptionLexicalHandler.endCDATA()
public void comment(char[] ary,
int start,
int length)
throws SAXException
AbstractXMLPipe
comment in interface LexicalHandlercomment in class AbstractXMLPipeary - An array holding the characters in the comment.start - The starting position in the array.length - The number of characters to use from the array.
SAXExceptionLexicalHandler.comment(char[], int, int)protected void addRecorder(XMLConsumer recorder)
protected Object removeRecorder()
public void startSAXRecording()
throws SAXException
endSAXRecording() call.
SAXException
public XMLizable endSAXRecording()
throws SAXException
SAXException
public void startTextRecording()
throws SAXException
SAXException
public String endTextRecording()
throws SAXException
SAXException
public void startSerializedXMLRecording(Properties format)
throws SAXException
format - The format for the serialized output. If null
is specified, the default format is used.
SAXException
public String endSerializedXMLRecording()
throws SAXException,
ProcessingException
SAXException
ProcessingException
public void startParametersRecording()
throws SAXException
SAXException
public SourceParameters endParametersRecording(Parameters source)
throws SAXException
source - An optional parameters object.
SAXException
public SourceParameters endParametersRecording(SourceParameters source)
throws SAXException
source - An optional parameters object.
SAXException
public void startRecording()
throws SAXException
endRecording() call.
SAXException
public DocumentFragment endRecording()
throws SAXException
SAXException
public void setupTransforming()
throws IOException,
ProcessingException,
SAXException
IOException
ProcessingException
SAXException
public void startTransformingElement(String uri,
String name,
String raw,
Attributes attr)
throws ProcessingException,
IOException,
SAXException
uri - The namespace of the element.name - The local name of the element.raw - The qualified name of the element.attr - The attributes of the element.
ProcessingException
IOException
SAXException
public void endTransformingElement(String uri,
String name,
String raw)
throws ProcessingException,
IOException,
SAXException
uri - The namespace of the element.name - The local name of the element.raw - The qualified name of the element.
ProcessingException
IOException
SAXException
public void sendTextEvent(String text)
throws SAXException
text - The string containing the information.
SAXException
public void sendStartElementEvent(String localname)
throws SAXException
localname - The name of the event.
SAXException
public void sendStartElementEventNS(String localname)
throws SAXException
localname - The name of the event.
SAXException
public void sendStartElementEvent(String localname,
Attributes attr)
throws SAXException
localname - The name of the event.attr - The Attributes of the element
SAXException
public void sendStartElementEventNS(String localname,
Attributes attr)
throws SAXException
localname - The name of the event.attr - The Attributes of the element
SAXException
public void sendEndElementEvent(String localname)
throws SAXException
localname - The name of the event.
SAXException
public void sendEndElementEventNS(String localname)
throws SAXException
localname - The name of the event.
SAXException
public void sendEvents(Node node)
throws SAXException
node - The tree to be included.
SAXException
public void sendParametersEvents(SourceParameters pars)
throws SAXException
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.
SAXException
protected void sendStartPrefixMapping()
throws SAXException
SAXException
protected void sendEndPrefixMapping()
throws SAXException
SAXExceptionprotected String findPrefixMapping(String uri)
protected AttributesImpl getMutableAttributes(Attributes a)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||