AnsweredAssumed Answered

OpenOffice XSLT XML data merge

Question asked by snowch on Mar 1, 2009
Latest reply on May 28, 2009 by jayjayecl
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

Outcomes