HOW TO USE OPENOFFICE FILES IN A GENERATOR IN COCOON.
Author: Yves Vindevogel \\Date: 2003-03-14 ---- Hi all,
I think I got a solution to use OpenOffice (Writer) files as a generator in Cocoon.
First of all, thanks to Conal Tuohyand Upayavirafor pointing me at some very important details.
Okay, what I did ....
1. files and folders
My cocoon folder looks like this: \\cocoon/resources/entities
The sitemap for the Implements site is mounted as a submap of the sitemap in the /cocoon directory.
I've got the file "test.sxw" in my directory /implements/sxw \\I've got the file "html.oowriter.xsl" in my directory /implements/xsl \\I've got the files from, in my case opt/OpenOffice.org1.0/share/dtd/officedocument/1_0 \\(the DTDs from OpenOffice) copied to the folder /cocoon/resources/entities
This is my sitemap (well, the part for OO)
The basic element is this one is the "jar:http://" thing. Thanks to Conal for pointing me to this. OpenOffices uses a kind of zip file to store its files in. The Jar: protocol is able to read those zips straight away. Conal made a wiki page for this: \\JarProtocolExample
The only problem is the need for a "http://web/....". \\You need to specify the full path, the Jar: protocol does not work with the cocoon sitemap.
His wiki page shows the <map:read>, which works fine. You can read whatever you want from the zip file.
I went further: I wanted to use the content.xml in that zip in a generator. \\So I changed the <map:read> into <map:generate> \\This results in an error:
\\message File "jar:http://web/implements/test.sxw!/office.dtd" not found.
This is correct, the dtd is not in the zipped file. It's only a reference.
4. Fixing problem 1: modify the catalog
I modified the /resources/entities/catalog file. I added two lines \\(Thanks Upayavira for showing me this thing)
\\-- Open Office DTDs --
That corrects the error, but gives a new one ....
5. Fixing problem 2: modify the DTD
Appearantly, there's something in that file. I looked at it, but I could not find a mistake. I'm not an expert on those things, so, maybe someone can look into it for me ....
I used a workaround however. You can modify the /resources/entities/office.dtd (from OO) file. There's entries like this:
\\<!ENTITY % dtypes-mod SYSTEM "dtypes.mod">
When you remove them all, the generator should work (Sax does not check a lot, this is a workaround, not a solution ;--)))
Next thing I did, was to use the <map:aggregate> to combine the files from the zipped file into one. I enclose the original xml from all the files in a new <document> tag. At first, I used the <office:document> tag, but this gave problems in my XSL.
After that, it outputs both files as a combined xml file, like we needed !
7. Sample XSL
I then reused an xsl file I wrote before, when I extracted the files to xml with a little perl too. This xsl file generates a very simple page in html, based on the document ...
\\<?xml version="1.0" encoding="UTF-8"?>
Et voila !!!! That's it .... \\Once again, thanks to all who helped.
Could somebody please check this to see if he/she could reproduce my work on his/her machine ??
Implements \\Mail: email@example.com-- http://www.implements.be
Quote: The winner never says participating is more important than winning.