cancel
Showing results for 
Search instead for 
Did you mean: 

OpenOffice XSLT XML data merge

snowch
Champ in-the-making
Champ in-the-making
I have created a prototype project for a standalone document service that works by applying external data to an OpenOffice document using XSLT. 

The service works by unpacking the odf, extracting the relevant file (e.g. content.xml), and applying data from an external xml file.  The new merged file is then repackaged into the odf and a conversion process allows you to convert the file to various formats (pdf, etc).

Example XSLT:

<?xml version="1.0"?>
<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
   version="1.0">

   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="node()|@*">
     <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>
   </xsl:template>
   
   <xsl:template match="text:p[text() = 'Replace me!']">
         <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:value-of select="document('data.xml')/map/entry[@key='key1']/@value"/>
         </xsl:copy>
   </xsl:template>
</xsl:stylesheet>

The benefit of using XSLT on the ODF file in this manner allows business users to provide document templates.   Developers can then create the XSLT to fill the document template without having to modify the original ODF file.

Is functionality similar to above available in Alfresco?

Many thanks in advance,

Chris
4 REPLIES 4

jayjayecl
Confirmed Champ
Confirmed Champ
Hi,

I have the same kind of requirement.
I have a "template file" in OpenOffice text Format, whici holds some variables (like "${reference}").
I have a Java class that builds a HashMap of (key, value).
I'd like to generate a PDF document from de odf template file, and the Map of data (as I would be able to do easily with freemarker).
What is the best practice to do that ?

jayjayecl
Confirmed Champ
Confirmed Champ
Found a solution using JodReports (you ll find it on sourceforge)

zaizi
Champ in-the-making
Champ in-the-making
FYI: from JodReports website

Warning! This project is now unmaintained. The latest version 2.0.0 was released back in September 2006. You may still find it useful, since it is open source you are free to get the code and modify it, but be aware that the original author is no longer developing it.

jayjayecl
Confirmed Champ
Confirmed Champ
I know, I saw it, but still, I tried and it worked.
FYI, a part of the project JODREPORTS is already included in Alfresco : jodconverter.

Thank you anyway