ODF Template Engine

Embed Size (px)

Citation preview

ODF Template Engine

An easy document generation tool built with ODFDOM

Ying Chun GuoTechnical LeadODF ToolkitSoftware StandardsIBM Software Group

15:00-15:45Nov 5th, 2009

@ 2009 IBM Corporation

Agenda

Overview

Implemented with ODFDOM

A CDA use case

Extension and configuration

Summary

This prensentation is for reference only, IBM does not provide any kind of warranty/guaranty to it.

Documents generation from template is a common requirement in many documents processing solutions.

ODF Template Engine is a tool to generate ODF documents based on template.

A template is a fully-formatted text document with substitution blocks indicated with special delimiters.

The substitution blocks will be replaced with data from data sources.

Mappings between the substitution blocks and data are defined in XML format.

Overview

Overview

ODF Template Engine is built with ODFDOM.

ODF Template Engine is easily configurable and extendable.

ODF Template Engine doesn't depend on any ODF editors.

ODF Template Engine focuses on server side processing.

Implemented with ODFDOM

Leverage ODFDOM navigation APIs to search the substitution blocks and replace them with data.

String pattern = delimiterLeftCharacter + "([a-zA-Z0-9_#\\-]+)" + delimiterRightCharacter;TextNavigation search = new TextNavigation(pattern, doc);while (search.hasNext()) {TextSelection item = (TextSelection) search.getCurrentItem();String text = item.getText();String data = dataRender.render(text);item.replaceWith(data);}

Implemented with ODFDOM

Leverage ODFDOM table convenient APIs to create rows and cells to display repeated data.

OdfTableRow tr = (OdfTableRow) table.appendChild(new OdfTableRow(contentDom));OdfTableCell td = (OdfTableCell) tr.appendCell(new OdfTableCell(contentDom));td.newTextPElement().setNodeValue(values[i]);

A CDA use case

Clinical documents, such as a discharge summary or progress note, are stored as CDA format in heathcare solutions.

If a patient wants to keep electronic versions of his/her clinical documents, there is a need to convert CDA XML documents to ODF format.

In this case, a discharge summary in ODF format can be generated from CDA XML document

Note: CDA is an XML-based markup standard that specifies the structure and semantics of a clinical document for the purpose of exchange.

A CDA use case

A CDA use case live demo : step 1

Define template and mapping file

Lotus Symphony plugin can help to do it.

A CDA use case live demo : step 2

Invoke the template engine by APIs:

//Create OdfTemplate instance and DataRender instance.OdfTemplate odftemp = OdfTemplate.loadTemplate(fileName,propFile);DataRender ddf = DataRender.parseDDF(new FileInputStream(ddfile));

//Create OdfTemplateTranslate instance and register a modifier handlerOdfTemplateTranslate engine = new OdfTemplateTranslate();HashmarkModifierHandler handler = new HashmarkModifierHandler();engine.registerHandler(handler);

//Run template engine to generate documentengine.generateODF(odftemp, ddf, parentPath);

Extension and configuration

User can introduce his own modifier handler by implement interface ModifierHandler and register the modifier handler in template engine.

Extension and configuration

User can support his own data source and data structure by extending class DataSource and implementing interface DataStructure

Summary

ODF Template Engine is an easy document generation tool which

doesn't depend on any ODF editors;

focus on server side processing;

is easily extendable and configurable.

ODFDOM can be leveraged to process ODF document.

You can get more information of ODF Toolkit from ODF Toolkit Union

Thank you!
[email protected]

Click to edit the title text format

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level

Fifth Outlin Level

Sixth Outline Level

Seventh Outline Level

Eighth Outline Level

Ninth Outline Level

Click to edit the notes format

Add your slide title here

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level

Fifth Outline Level

Sixth Outline Level

Seventh Outline Level

Eighth Outline Level

Ninth Outline Level

Slide

Click to edit the notes format

Click to edit the title text format

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level

Fifth Outline Level

Sixth Outline Level

Seventh Outline Level

Eighth Outline Level

Ninth Outline Level