|
||||||||||
| 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.generation.AbstractGenerator
org.apache.cocoon.generation.ServiceableGenerator
org.apache.cocoon.generation.FileGenerator
org.apache.cocoon.generation.CSVGenerator
public class CSVGenerator
A simple parser converting a Comma Separated Values (CSV) file into XML.
This parser is controlled by the following sitemap parameters:
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.
| Field Summary | |
|---|---|
static String |
NAMESPACE_PREFIX
The namespace prefix of XML generated by this instance. |
static String |
NAMESPACE_URI
The namespace URI of XML generated by this instance. |
| Fields inherited from class org.apache.cocoon.generation.FileGenerator |
|---|
inputSource |
| Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator |
|---|
manager |
| Fields inherited from class org.apache.cocoon.generation.AbstractGenerator |
|---|
objectModel, parameters, resolver, source |
| Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
|---|
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer |
| Fields inherited from interface org.apache.cocoon.generation.Generator |
|---|
ROLE |
| Constructor Summary | |
|---|---|
CSVGenerator()
Create a new CSVGenerator instance. |
|
| Method Summary | |
|---|---|
void |
generate()
Generate XML data from a Comma Separated Value resource. |
Serializable |
getKey()
Generate the unique key. |
void |
recycle()
Recycle this component. |
void |
setup(SourceResolver resolver,
Map object_model,
String source,
Parameters parameters)
Setup this CSVGenerator instance. |
| Methods inherited from class org.apache.cocoon.generation.FileGenerator |
|---|
getValidity |
| Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator |
|---|
dispose, service |
| 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 |
|---|
public static final String NAMESPACE_URI
The namespace URI of XML generated by this instance.
public static final String NAMESPACE_PREFIX
The namespace prefix of XML generated by this instance.
| Constructor Detail |
|---|
public CSVGenerator()
Create a new CSVGenerator instance.
| Method Detail |
|---|
public void recycle()
Recycle this component.
.
recycle in interface Recyclablerecycle in class FileGenerator
public void setup(SourceResolver resolver,
Map object_model,
String source,
Parameters parameters)
throws ProcessingException,
SAXException,
IOException
Setup this CSVGenerator instance.
setup in interface SitemapModelComponentsetup in class FileGeneratorProcessingException
SAXException
IOExceptionpublic Serializable getKey()
Generate the unique key.
getKey in interface CacheableProcessingComponentgetKey in class FileGenerator
public void generate()
throws IOException,
SAXException,
ProcessingException
Generate XML data from a Comma Separated Value resource.
.
generate in interface Generatorgenerate in class FileGeneratorIOException
SAXException
ProcessingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||