You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Apache Wiki <wi...@apache.org> on 2005/05/14 22:56:10 UTC

[Lenya Wiki] Update of "WyonaOpenOffice" by GregorRothfuss

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Lenya Wiki" for change notification.

The following page has been changed by GregorRothfuss:
http://wiki.apache.org/lenya/WyonaOpenOffice

The comment on the change is:
obsolete

------------------------------------------------------------------------------
- ''Note: This information is slightly outdated and with !OpenOffice1.1 I would no longer recommend this approach''
+ deleted
  
- This document describes the integration of Openoffice with Lenya CMS. The integration is guided by the following goals:
- 
-  *  Use !OpenOffice as a content editor for static web pages
-  *  Migrate !OpenOffice document to a custom xml format
- 
- == Prerequisites ==
- 
- In order to seamlessly integrate Openoffice into the publication process of Lenya/Cocoon the following prerequisites need to be met:
- 
- == OpenOffice DTD ==
- 
- The DTDs for the !OpenOffice documents has to be available on the system.
- 
- It's best to get them directly from your !OpenOffice installation. They are located in the share directory of your installation. Copy the dtd's into your Lenya installation, e.g. as follows:
- 
- {{{
- cp ~/Office/share/dtd/* ~/build/jakarta-tomcat-4.1.18-LE-jdk14/webapps/lenya/lenya/resources/dtd/openoffice/
- }}}
- 
- ''FIXME:The DTDs should probably go into /usr/share/sgml/openoffice/*''
- 
- ''Note: There's a bug in the xml parser. As a workaround we uncomment all the {{{draw:text-box}}} stuff.''
- 
- ''Note: usually, an empty file is enougn as a DTD for an XML parser if there's no validation''
- 
- 
- === XML Catalog ===
- 
- In order for Lenya/Cocoon to find the DTDs you need to setup an XML catalog as follows:
- 
- {{{
- xmlcatalog --noout --create openoffice.cat
- xmlcatalog --noout --add "public" \
-   "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" 
-   "file:///home/slide/build/jakarta-tomcat-4.1.18-LE-jdk14/webapps/lenya/lenya/resources/dtd/openoffice/officedocument/1_0/office.dtd" \
-   openoffice.cat
- }}}
- 
- Alternatively you can simply use the attached catalog.
- 
- Store this newly created catalog and edit !CatalogManager.properties to
- make sure Cocoon finds this catalog and hence the !OpenOffice DTDs.
- 
- Add the location of the !OpenOffice catalog to Cocoon's !CatalogManager.properties (which can be found in
- {{{~/build/jakarta-tomcat-4.1.18-LE-jdk14/webapps/lenya/WEB-INF/classes/CatalogManager.properties}}})
- by adding the following lines to this file:
- 
- 
- {{{
- #catalogs=/path/to/local/catalog
- catalogs=/home/slide/build/jakarta-tomcat-4.1.18-LE-jdk14/webapps/lenya/lenya/resources/dtd/openoffice/catalog.xml
- }}}
- 
- == OpenOffice2HTML XSTL ==
- 
- In order to render the !OpenOffice xml as html we need XSLT stylesheets
- to provide the necessary transformations.
- 
- A very good XSLT which is fairly complete can be fetched from zope.org ([http://www.zope.org/Members/philikon/ZooDocument]).
- 
- === Slide ===
- 
- Slide is an Apache project which offers amongst other things a a
- WebDAV access module (implemented as a servlet). This will allow us to
- deploy the !OpenOffice documents directly via WebDAV.
- 
- For a very basic installation the following changes need to be applied
- to a file named Domain.xml in the Slide webapp directory:
- 
-  *  Change permissions
-  *  !ContentStore: set to parent dir of !OpenOffice dir
-  *  Replace folder "files" by !OpenOffice dir name
- 
- The following patch will apply all changes you need:
- 
- {{{
- diff -u Domain.xml.orig Domain.xml
- --- Domain.xml.orig	Thu Nov  1 15:47:52 2001
- +++ Domain.xml		Thu Mar 20 16:44:09 2003
- @@ -44,7 +44,7 @@
-            <reference store="nodestore" />;
-          </revisiondescriptorstore>;
-          <contentstore classname="slidestore.reference.FileContentStore">
- -          <parameter name="rootpath">contentstore</parameter>
- +          <parameter name="rootpath">/home/slide/build/jakarta-tomcat-4.1.18-LE-jdk14/webapps/lenya/lenya/pubs/computerworld/content/authoring&lt;/parameter&gt;
-            <parameter name="version">false</parameter>
-            <parameter name="resetBeforeStarting">true</parameter>
-          &lt;/contentstore&gt;
- @@ -136,7 +136,7 @@
-        <!-- Paths configuration -->;
-        <userspath>/users</userspath>
-        <guestpath>guest&lt;/guestpath>
- -      <filespath>/files&lt;/filespath>
- +      <filespath>/openoffice</filespath>
-        <parameter name="dav">true</parameter>
-        <parameter name="standalone">true</parameter>
-  
- @@ -245,13 +245,12 @@
-            
-          </objectnode>
-          
- -        <objectnode classname="org.apache.slide.structure.SubjectNode" 
- -         uri="/files">
- +        <objectnode classname="org.apache.slide.structure.SubjectNode" uri="/openoffice">
-  
-            <!-- ### Give read/write/manage permission to guest ### 
-                 Uncomment the following line to give permission to do
-                 all actions on /files to guest (unauthenticated users) -->
- -          <!-- <permission action="/actions" subject="/users/guest"/> -->
- +          <permission action="/actions" subject="/users/guest"/>
-  
-            <permission action="/actions/manage" subject="/users/john"/>
-            <permission action="/actions/write" subject="+/users/groupA"/>
- }}}
- 
- == Pipelines ==
- 
- In order for Lenya/Cocoon to be able to read the content of the
- === OpenOffice document, a set of pipelines need to be set up. ===
- 
- === Read the zip/jar file ===
- 	
- To read the !OpenOffice documents we need to setup a simple reader which as follows:
- 
- {{{	
- <map:match pattern="**.sxw">
-   <map:read src="content/{1}.sxw"/>
- </map:match>
- }}}
- 
- === Unpack zip file and transform the OO xml to xhtml ===
- 
- === OpenOffice documents are actually a zip file containing xml files for ===
- content and style plus other additional files such as jpg etc.
- 
- Zip is the same file format as jar. JDK supports jar unpacking
- natively with the jar protocol. The pipeline to read a jar file looks
- as follows:
- 
- {{{
- <map:match pattern="**.oo">
-   <map:generate src="jar:http://localhost:38080/lenya/computerworld/authoring/{1}.sxw!/content.xml"/>
-   <map:transform src="../../xslt/openoffice/ooo2html.xsl"/>
-   <map:serialize/>
- </map:match>
- }}}
- 
- ''Tip:you can use request parameters to avoid hardcoded URLs http://{request:serverName}:{request:serverPort} InputModules''
- 
- === Aggregate with navigation ===
- 
- Additionaly we want to embed the !OpenOffice document in the usual
- navigation, header and footer. The following is fairly specific to the
- Computerworld publication but can easily be adapted:
- 
- {{{
- <map:match pattern="**.html">
-   <map:aggregate element="lenya">
-     <map:part src="cocoon:/menus/static/{1}.html"/>
-     <map:part element="cmsbody" src="content/authoring/wrapper.html"/>
-     <map:part src="cocoon:/{1}.oo" element="wrapper"/>
-     <map:part src="content/authoring/small-preview.xml"/>
-     <map:part src="content/authoring/sitetree.xml"/>
-     <map:part src="cocoon:/today"/>
-   </map:aggregate>
- 
-   <map:transform src="xslt/authoring/wrapper.xsl">
-     <map:parameter name="id" value="/{1}"/>
-     <map:parameter name="authoring" value="true"/>
-   </map:transform>
-   <map:transform src="xslt/authoring/images.xsl"/>
-   <map:serialize type="html"/>
- </map:match>
- }}}
- 
- == Problems ==
- 
-  * Caching prevents an update OO file (zip file) from being displayed.
- 
- '''workaround''' a deflat action to synchronize zip date and deflated entries. Easiest is an [:XSPAction], compiles by cocoon with no jar to add. Sitemap snippet
- 
- {{{
- <map:match pattern="**!**.xml">
-   <map:act type="serverpages" src="actions/deflat.xsp">
-     <!-- absolute file path of the file to deflat -->
-     <map:parameter name="zip" value="{global:content}/{1}"/>
-     <!-- path of the file to retrieve, deflated relatively to {path} -->
-     <map:parameter name="entry" value="{2}.xml"/>
-     <!-- relative path to define a unique directory where to deflat, 
- relatively to {work-dir}/cache/ -->
-     <map:parameter name="path" value="{1}~"/>
-     <!-- this action output an absolute file path where the file requested is deflated -->
-     <map:generate src="{file}"/>
-     <!-- implemented as a generator for agregation -->
-     <map:serialize type="xml"/>
-   </map:act>
- </map:match>
- }}}
- 
- xsp action source
- 
- {{{
- <?xml version="1.0" encoding="UTF-8"?>
- <xsp:page language="java" xmlns:action="http://apache.org/cocoon/action/1.0" xmlns:xsp="http://apache.org/xsp">
-     <xsp:structure>
-         <xsp:include>org.apache.cocoon.environment.Session</xsp:include>
-         <xsp:include>java.util.zip.*</xsp:include>
-         <xsp:include>java.util.*</xsp:include>
-         <xsp:include>java.io.*</xsp:include>
-         <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include>
-     </xsp:structure>
-     <!--
-     This xsp action use cocoon taglib action.xsl to get some context,
-     action.xsl is not used for inline tags (less easier than a simple java line)
- 
- 		When an entry in a zip is requested, it is deflated as a file
- 		workaround of jar:protocol, impossible to refresh
- -->
- 		<xsp:logic>
- 
- 	// get from cocoon2.0 sources, perhaps there's better somewhere
- 
- 	/** Contextualize this class */
- 	File context_work_dir;
- 	public void contextualize(Context context) throws ContextException {
- 		context_work_dir = (File) context.get(Constants.CONTEXT_WORK_DIR);
- 	}
-   </xsp:logic>
- 
-     <view>
-         <xsp:logic><![CDATA[ 
-         
- 
-   String entry=parameters.getParameter("entry", null);
-   String path=parameters.getParameter("path", null);
- 
- 	File file=new File(context_work_dir, "cache/"+path + "/" + entry);
-   File zip=new File(parameters.getParameter("zip", null));
- 	if (!zip.exists()) throw new ProcessingException ("deflat.xsp Action : "
- + zip + " doesn't exist");
- 
- 	// zip newer, deflat requested file
- 
-   if( file.lastModified() <= zip.lastModified() ) {
- 	  ZipInputStream in = new ZipInputStream(new FileInputStream(zip));
- 
- 
- 	  ZipEntry zipEntry;
- 	  do {
- 	      zipEntry = in.getNextEntry();
- 	  } while (zipEntry!=null &&  !entry.equals(zipEntry.getName())  );
- 
- 	  if (zipEntry==null) throw new ProcessingException ("deflat.xsp Action : " 
- + entry + " in " + zip + " doesn't exist");
- 
- 
- 		file.getParentFile().mkdirs();
- 		OutputStream out = new FileOutputStream(file);
- 
- 		byte[] buf = new byte[1024];
- 		int len;
- 		while ((len = in.read(buf)) > 0) {
- 		    out.write(buf, 0, len);
- 		}
- 		// Close the streams
- 		out.close();
- 		in.close();
- 	}
- 	
- 	// give the path of generated file as a sitemap parameter
- 	
- 	this.actionResultMap.put("file", file);
- 
- 	// action always true to have better debug information
- 
- 	try {	
-         if (true) this.objectModel.put(ServerPagesAction.ACTION_SUCCESS_OBJECT, Boolean.TRUE);
-         else this.objectModel.put(ServerPagesAction.ACTION_SUCCESS_OBJECT, Boolean.FALSE);
-     } 
-     catch (Exception e) {this.objectModel.put(ServerPagesAction.ACTION_SUCCESS_OBJECT, Boolean.FALSE);}
-   ]]></xsp:logic>
-     </view>
- </xsp:page>
- }}}
- 
- 
-  * If you restart tomcat (slide) you lose the !NodeContentStore so that WebDAV loses the nodes (documents and folders).
- 
-  *  xml parser cannot handle openoffice dtd's due to a parser bug
- 
- ''? works for me with empty files''
- 
- == To do's ==
- 
-  *  Set permissions in tomcat/slide: authorization and autorisation
-  *  Complete and improve !OpenOffice2Html xslt (images, tables, etc.)
- 
- ''Docbook default transfomations may be easily adapted for tables''
- 
-  *  Add pipelines for other files in zip like images
- 
- Done with this kind of match
- 
- {{{
- <xsl:template match="draw:image">
-   <xsl:element name="img">
-     <xsl:if test="svg:desc">
-        <xsl:attribute name="alt">
-           <xsl:value-of select="svg:desc"/>
-        </xsl:attribute>
-     </xsl:if>
-     <xsl:choose>
-       <xsl:when test="contains(@xlink:href, '#Pictures/')">
-           <xsl:attribute name="src">
-             <xsl:value-of select="concat($sxw, '!', substring-after(@xlink:href, '#'))"/>
-          </xsl:attribute>
-       </xsl:when>
-       <xsl:otherwise>
-          <xsl:value-of select="@xlink:href"/>
-       </xsl:otherwise>
-     </xsl:choose>
-   </xsl:element>
- </xsl:template>
- }}}
- 
- Handled by a sitemap pipeline in the style of upper
- 
- {{{
- <map:match pattern="**!**">
-   <map:act type="serverpages" src="actions/deflat.xsp">
-     <map:parameter name="zip" value="{global:content}/{1}"/>
-     <map:parameter name="entry" value="{2}"/>
-     <map:parameter name="path" value="{1}"/>
-     <map:read src="{file}"/>
-   </map:act>
- </map:match>
- }}}
- 
-  *  Integration slide and lenya
- 
- 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org