Package org.ametys.core.cocoon
Class CSVTransformer
- All Implemented Interfaces:
Poolable,Recyclable,Component,LogEnabled,SitemapModelComponent,Transformer,XMLConsumer,XMLPipe,XMLProducer,XMLConsumer,ContentHandler,LexicalHandler
This transformer is in charge to transform XML to CSV format with escaped and sanitized cell values.
XML input should respect the following format:
With preceded example, ouput will be:
XML input should respect the following format:
<csv>
<row>
<cell>Header 1</cell>
<cell>Header 2</cell>
<cell>Header 3</cell>
<cell>Header 4</cell>
</row>
<row>
<cell>A cell value with "double quotes"</cell>
<cell></cell>
<cell>=1+2</cell>
<cell doNotSanitize="true">=1+2</cell>
</row>
</csv>
Use do 'doNotSanitize' attribute on tag <cell> to skip sanitization of the cell.With preceded example, ouput will be:
"Header 1";"Header 2";"Header 3";"Header 4"; "A cell value with ""double quotes""";;"'=1+2";"=1+2"
-
Field Summary
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumerFields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) voidendElement(String uri, String localName, String raw) voidsetup(SourceResolver resolver, Map objectModel, String src, Parameters par) voidstartElement(String uri, String localName, String raw, Attributes atts) Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMappingMethods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
recycle, setConsumer, setContentHandler, setLexicalHandlerMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration, endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMappingMethods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntityMethods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
-
Constructor Details
-
CSVTransformer
public CSVTransformer()
-
-
Method Details
-
startElement
public void startElement(String uri, String localName, String raw, Attributes atts) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classAbstractXMLPipe- Throws:
SAXException
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classAbstractXMLPipe- Throws:
SAXException
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classAbstractXMLPipe- Throws:
SAXException
-
setup
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException
-