org.apache.cocoon.optional.pipeline.components.sax.csv
Class CSVGenerator

java.lang.Object
  extended by org.apache.cocoon.pipeline.component.AbstractPipelineComponent
      extended by org.apache.cocoon.sax.AbstractSAXPipelineComponent
          extended by org.apache.cocoon.sax.AbstractSAXProducer
              extended by org.apache.cocoon.sax.AbstractSAXGenerator
                  extended by org.apache.cocoon.optional.pipeline.components.sax.csv.CSVGenerator
All Implemented Interfaces:
PipelineComponent, Producer, Starter, SAXPipelineComponent, SAXProducer

public class CSVGenerator
extends AbstractSAXGenerator

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.
 
Constructor Summary
CSVGenerator()
           Create a new CSVGenerator instance.
CSVGenerator(String csv)
           
 
Method Summary
 void execute()
           
 void recycle()
           
 void setConfiguration(Map<String,? extends Object> configuration)
          Pass component specific configuration parameters to the pipeline component in a generic way.
 
Methods inherited from class org.apache.cocoon.sax.AbstractSAXProducer
getSAXConsumer, setConsumer, setSAXConsumer, toString
 
Methods inherited from class org.apache.cocoon.pipeline.component.AbstractPipelineComponent
finish, setup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.pipeline.component.PipelineComponent
finish, setup
 

Field Detail

NAMESPACE_URI

public static final String NAMESPACE_URI

The namespace URI of XML generated by this instance.

See Also:
Constant Field Values

NAMESPACE_PREFIX

public static final String NAMESPACE_PREFIX

The namespace prefix of XML generated by this instance.

See Also:
Constant Field Values
Constructor Detail

CSVGenerator

public CSVGenerator()

Create a new CSVGenerator instance.


CSVGenerator

public CSVGenerator(String csv)
Method Detail

recycle

public void recycle()

setConfiguration

public void setConfiguration(Map<String,? extends Object> configuration)
Description copied from interface: PipelineComponent
Pass component specific configuration parameters to the pipeline component in a generic way. This is useful in environments that automatically assemble pipelines with their components and can't use the components constructors or setters.

Specified by:
setConfiguration in interface PipelineComponent
Overrides:
setConfiguration in class AbstractPipelineComponent
Parameters:
configuration - The Map of configuration parameters.

execute

public void execute()


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.