| org.apache.cocoon.transformation.AbstractTransformer org.apache.cocoon.transformation.AbstractSAXTransformer org.apache.cocoon.transformation.CleanupTransformer
CleanupTransformer | public class CleanupTransformer extends AbstractSAXTransformer implements CacheableProcessingComponent(Code) | | Cleanup transformer: Removes excess whitespace while adding some where needed
for legibility. Strips unwanted namespace declarations.
The cleanup transformer can be used for basically any document as-is or customized by
schema (inline vs. block elements) for easier reading.
Transformer declaration:
<map:components>
<map:transformers>
<map:transformer name="htmlcleanup"
src="org.apache.cocoon.transformation.CleanupTransformer">
<preserve-uri>*</preserve-uri>
</map:transformer>
<map:transformer name="xhtmlcleanup"
src="org.apache.cocoon.transformation.CleanupTransformer">
<inline-elements>a,abbr,acronym,b,br,font,i,u,img</inline-elements>
<preserve-uri>http://www.w3.org/1999/xhtml</preserve-uri>
</map:transformer>
</map:transformers>
</map:components>
The "inline-elements" configuration element refers to a list of element names that are
not to be indented. The "preserve-uri" configuration element specifies a
namespace uri mapping that is meant for output. All other namespace declarations are
stripped from the output. The "preserve-uri" element may appear more than once. If
"preserve-uri" is omitted, all namespaces/prefixes are removed from the output.
Transformer usage:
<transform type="xhtmlcleanup">
<map:parameter name="indent-size" value="4"/>
</transform>
The optional parameter "indent-size" specifies the number of additional space characters
appearing at each level of the output document. The default value is 2.
Bugs: Nested namespace declarations with the same namespace prefix will break the code.
author: Miles Elam |
Method Summary | |
public void | characters(char[] ch, int start, int length) | public void | configure(Configuration conf) | public void | endElement(String uri, String qName, String lName) | public void | endPrefixMapping(String prefix) | public Serializable | getKey() | public SourceValidity | getValidity() | public void | ignorableWhitespace(char[] ch, int start, int length) | public void | recycle() | public void | setup(SourceResolver resolver, Map objectModel, String src, Parameters par) | public void | startElement(String uri, String qName, String lName, Attributes attrs) | public void | startPrefixMapping(String prefix, String uri) |
Methods inherited from org.apache.cocoon.transformation.AbstractSAXTransformer | protected void addRecorder(XMLConsumer recorder)(Code)(Java Doc) public void characters(char[] p0, int p1, int p2) throws SAXException(Code)(Java Doc) public void comment(char ary, int start, int length) throws SAXException(Code)(Java Doc) public void configure(Configuration configuration) throws ConfigurationException(Code)(Java Doc) public void dispose()(Code)(Java Doc) public void endCDATA() throws SAXException(Code)(Java Doc) public void endDTD() throws SAXException(Code)(Java Doc) public void endDocument() throws SAXException(Code)(Java Doc) public void endElement(String uri, String name, String raw) throws SAXException(Code)(Java Doc) public void endEntity(String name) throws SAXException(Code)(Java Doc) public SourceParameters endParametersRecording(Parameters source) throws SAXException(Code)(Java Doc) public SourceParameters endParametersRecording(SourceParameters source) throws SAXException(Code)(Java Doc) public void endPrefixMapping(String prefix) throws SAXException(Code)(Java Doc) public DocumentFragment endRecording() throws SAXException(Code)(Java Doc) public XMLizable endSAXRecording() throws SAXException(Code)(Java Doc) public String endSerializedXMLRecording() throws SAXException, ProcessingException(Code)(Java Doc) public String endTextRecording() throws SAXException(Code)(Java Doc) public void endTransformingElement(String uri, String name, String raw) throws ProcessingException, IOException, SAXException(Code)(Java Doc) protected String findPrefixMapping(String uri)(Code)(Java Doc) protected AttributesImpl getMutableAttributes(Attributes a)(Code)(Java Doc) public void ignorableWhitespace(char[] p0, int p1, int p2) throws SAXException(Code)(Java Doc) public void processingInstruction(String target, String data) throws SAXException(Code)(Java Doc) public void recycle()(Code)(Java Doc) protected Object removeRecorder()(Code)(Java Doc) public void sendEndElementEvent(String localname) throws SAXException(Code)(Java Doc) public void sendEndElementEventNS(String localname) throws SAXException(Code)(Java Doc) protected void sendEndPrefixMapping() throws SAXException(Code)(Java Doc) public void sendEvents(Node node) throws SAXException(Code)(Java Doc) public void sendParametersEvents(SourceParameters pars) throws SAXException(Code)(Java Doc) public void sendStartElementEvent(String localname) throws SAXException(Code)(Java Doc) public void sendStartElementEvent(String localname, Attributes attr) throws SAXException(Code)(Java Doc) public void sendStartElementEventNS(String localname) throws SAXException(Code)(Java Doc) public void sendStartElementEventNS(String localname, Attributes attr) throws SAXException(Code)(Java Doc) protected void sendStartPrefixMapping() throws SAXException(Code)(Java Doc) public void sendTextEvent(String text) throws SAXException(Code)(Java Doc) public void service(ServiceManager manager) throws ServiceException(Code)(Java Doc) public void setDocumentLocator(Locator locator)(Code)(Java Doc) public void setup(SourceResolver resolver, Map objectModel, String src, Parameters params) throws ProcessingException, SAXException, IOException(Code)(Java Doc) public void setupTransforming() throws IOException, ProcessingException, SAXException(Code)(Java Doc) public void skippedEntity(String name) throws SAXException(Code)(Java Doc) public void startCDATA() throws SAXException(Code)(Java Doc) public void startDTD(String name, String public_id, String system_id) throws SAXException(Code)(Java Doc) public void startDocument() throws SAXException(Code)(Java Doc) public void startElement(String uri, String name, String raw, Attributes attr) throws SAXException(Code)(Java Doc) public void startEntity(String name) throws SAXException(Code)(Java Doc) public void startParametersRecording() throws SAXException(Code)(Java Doc) public void startPrefixMapping(String prefix, String uri) throws SAXException(Code)(Java Doc) public void startRecording() throws SAXException(Code)(Java Doc) public void startSAXRecording() throws SAXException(Code)(Java Doc) public void startSerializedXMLRecording(Properties format) throws SAXException(Code)(Java Doc) public void startTextRecording() throws SAXException(Code)(Java Doc) public void startTransformingElement(String uri, String name, String raw, Attributes attr) throws ProcessingException, IOException, SAXException(Code)(Java Doc)
|
|
|