| org.apache.cocoon.generation.AbstractGenerator org.apache.cocoon.generation.ServiceableGenerator org.apache.cocoon.generation.FileGenerator org.apache.cocoon.generation.CSVGenerator
CSVGenerator | public class CSVGenerator extends FileGenerator (Code) | | A simple parser converting a Comma Separated Values (CSV) file into XML.
This parser is controlled by the following sitemap parameters:
-
process-headers: whether the first line in the CSV is considered
to be the header defining column names (the resulting output will be
different if this is true or false (default: false).
-
max-records: the maximum number of records to read
(default: -1 read all records).
-
encoding: the character encoding (UTF-8, ISO8859-1, ...) used to
interpret the input CSV source file (default: system default).
-
separator: the field-separator character in the CSV file (comma,
tab, ...) (default: , comma).
-
escape: the character used to escape fields, or part of them, in
the CSV file (default: " quote).
-
buffer-size: the size of the buffer used for reading the source
CSV file (default: 4096 bytes).
The generated output will look something like the following:
<?xml version="1.0" encoding="ISO-8859-1"?>
<csv:document xmlns:csv="http://apache.org/cocoon/csv/1.0">
<csv:header>
<csv:column number="1">Column A</csv:column>
<csv:column number="2">Column B</csv:column>
<csv:column number="3">Column C</csv:column>
</csv:header>
<csv:record number="1">
<csv:field number="1" column="Column A">Field A1</csv:field>
<csv:field number="2" column="Column B">Field B1</csv:field>
<csv:field number="3" column="Column C">Field C1</csv:field>
</csv:record>
<csv:record number="2">
<csv:field number="1" column="Column A">Field A2</csv:field>
<csv:field number="2" column="Column B">Field B2</csv:field>
<csv:field number="3" column="Column C">Field C2</csv:field>
</csv:record>
</csv:document>
Note that this generator has been thoroughly tested with CSV files generated
by Microsoft Excel.
Unfortunately no official CSV specification has ever been published by
any standard body, so the interpretation of the format might be slightly
different in cases.
author: Pier Fumagalli |
NAMESPACE_PREFIX | final public static String NAMESPACE_PREFIX(Code) | | The namespace prefix of XML generated by this instance.
|
NAMESPACE_URI | final public static String NAMESPACE_URI(Code) | | The namespace URI of XML generated by this instance.
|
recycle | public void recycle()(Code) | | Recycle this component. .
|
Fields inherited from org.apache.cocoon.generation.FileGenerator | protected Source inputSource(Code)(Java Doc)
|
Fields inherited from org.apache.cocoon.generation.ServiceableGenerator | protected ServiceManager manager(Code)(Java Doc)
|
Methods inherited from org.apache.cocoon.generation.ServiceableGenerator | public void dispose()(Code)(Java Doc) public void service(ServiceManager manager) throws ServiceException(Code)(Java Doc)
|
|
|