|
From: <tr...@us...> - 2003-08-07 21:09:05
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv5825/src/com/babeldoc/conversion/pipeline/stage
Modified Files:
FlatToXmlPipelineStage.java XlsToXmlPipelineStage.java
Log Message:
conversion code now can alter the output xml document
Index: FlatToXmlPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/pipeline/stage/FlatToXmlPipelineStage.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** FlatToXmlPipelineStage.java 19 Jul 2003 13:16:47 -0000 1.6
--- FlatToXmlPipelineStage.java 7 Aug 2003 21:09:02 -0000 1.7
***************
*** 68,71 ****
--- 68,72 ----
import com.babeldoc.conversion.ConversionHelper;
import com.babeldoc.conversion.flatfile.FlatFileConverter;
+ import com.babeldoc.conversion.flatfile.ConversionUnmarshaller;
import com.babeldoc.conversion.flatfile.digester.DigesterConversionUnmarshaller;
import com.babeldoc.core.I18n;
***************
*** 132,142 ****
InputStream input = getDocument().getInputStream();
PipelineDocument newDocument = ConversionHelper.render(new FlatFileConverter(
! new DigesterConversionUnmarshaller(config)).toXml(input), this.getDocument());
newDocument.setBinary(false);
return processHelper(newDocument);
! } catch (Exception except) {
! throw new PipelineException("[FlatToXmlPipelineStage] Process", except);
}
}
--- 133,144 ----
InputStream input = getDocument().getInputStream();
+ ConversionUnmarshaller unmarshaller = new DigesterConversionUnmarshaller(config);
PipelineDocument newDocument = ConversionHelper.render(new FlatFileConverter(
! unmarshaller).toXml(input), this.getDocument(), unmarshaller.getEncoding());
newDocument.setBinary(false);
return processHelper(newDocument);
! } catch (Exception e) {
! throw new PipelineException("[FlatToXmlPipelineStage] Process", e);
}
}
Index: XlsToXmlPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/pipeline/stage/XlsToXmlPipelineStage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** XlsToXmlPipelineStage.java 6 Aug 2003 00:12:05 -0000 1.4
--- XlsToXmlPipelineStage.java 7 Aug 2003 21:09:02 -0000 1.5
***************
*** 70,73 ****
--- 70,76 ----
import com.babeldoc.conversion.excel.ExcelConverter;
import com.babeldoc.core.pipeline.*;
+ import com.babeldoc.core.option.ConfigOption;
+ import com.babeldoc.core.option.IConfigOptionType;
+ import com.babeldoc.core.I18n;
import java.util.Collection;
***************
*** 75,88 ****
/**
! * @author dejank
*
! * To change this generated comment go to
! * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class XlsToXmlPipelineStage extends PipelineStage {
public static String DATE_FORMAT = "dd.mm.yyyy";
! public XlsToXmlPipelineStage() {
super(new PipelineStageInfo() {
public String getName() {
--- 78,97 ----
/**
! * Pipelinestage to convert Excel documents (.xls) into XML documents. This used the Apache POI library. The actual
! * conversion is handled in the ExcelConverter class. By default the XML encoding is UTF-8 unless the 'encoding'
! * configuration option is provided to the pipeline stage.
*
! * @author dejank
! * @version 1.1
*/
public class XlsToXmlPipelineStage extends PipelineStage {
public static String DATE_FORMAT = "dd.mm.yyyy";
+ public static final String ENCODING = "encoding";
! /**
! * Construct this stage - create the information object
! */
! public XlsToXmlPipelineStage() {
super(new PipelineStageInfo() {
public String getName() {
***************
*** 91,99 ****
public String getDescription() {
! return "Converts Microsoft Excel files to XML format.";
}
public Collection getTypeSpecificOptions() {
! return new ArrayList();
}
});
--- 100,115 ----
public String getDescription() {
! return I18n.get("conversion.pipeline.stage.XlsToXml.desc");
}
public Collection getTypeSpecificOptions() {
! Collection options = new ArrayList();
!
! //add specific options
! options.add(new ConfigOption(ENCODING,
! IConfigOptionType.STRING, null, false,
! I18n.get("conversion.pipeline.stage.XlsToXml.encoding")));
!
! return options;
}
});
***************
*** 103,119 ****
* Process. This converts the document from Microsoft Excel (tm) data format
* to an xml format. This uses the ExcelConverter.
! */
public PipelineStageResult[] process()
throws PipelineException {
try {
PipelineDocument doc = ConversionHelper.render(new ExcelConverter().toXml(this.getDocument().getInputStream()),
! this.getDocument());
doc.setBinary(false);
return processHelper(doc);
} catch (ConversionException e) {
! // TODO Auto-generated catch block
! throw new PipelineException("Error converting XLS file to XML");
}
}
--- 119,139 ----
* Process. This converts the document from Microsoft Excel (tm) data format
* to an xml format. This uses the ExcelConverter.
! *
! * @return array of pipelinestage results
! * @throws PipelineException
! */
public PipelineStageResult[] process()
throws PipelineException {
+ String encoding = this.getOptions(ENCODING);
+
try {
PipelineDocument doc = ConversionHelper.render(new ExcelConverter().toXml(this.getDocument().getInputStream()),
! this.getDocument(), encoding);
doc.setBinary(false);
return processHelper(doc);
} catch (ConversionException e) {
! throw new PipelineException(I18n.get("conversion.pipeline.stage.XlsToXml.error"), e);
}
}
|