cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriele Domenichini <gabrid...@fastmail.fm>
Subject Cocoon 2, Docbook and Norman Walsh's Stylesheets
Date Sat, 28 Sep 2002 08:34:36 GMT
I have succeded in transforming Docbook to pdf and to html on cocoon 2.0.3 
using the stylesheet by Norman Walsh on the official docbook repository 
(http://docbook.sourceforge.net/projects/xsl/index.html). 
Cocoon has some weakness in doing this and I spent 15 days to make it work 
properly, so if you want save some time and you want to do something similar 
you are interested in this mail.
What I learned is that:

1. While xalan can do docbook transformation to xslfo correctly from the 
command line, on cocoon it can't.

2. If you use Saxon instead of xalan the transformation is almost successful 
but not completly: ie. I lost all the sect1/title.

3. If you use Saxon you loose all the xsp capabilities in cocoon (I want to 
make sql transformation with as400 and Oracle)

4. Incremental processing is not suggested for docbook to pdf transformation

The solutions I have found to this problems thanks to all I have read on the 
mailing lists and on the official site is:
1. Setting up cocoon to use xalan and saxon in alternative (defult: xalan) and 
set incremental processing to false in Saxon

2. Renaming saxon.jar to z-saxon.jar (I am not sure if is necessary but in 
this way works)

3. Modifying Saxon to make it use the parser xerces instead of aelfred 

Let'see theese points in detail

1. Setting up cocoon to use xalan and saxon in alternative (defult: xalan) and 
set incremental processing to false in Saxon.
To do this:
1.1 Put saxon652.jar WEB-INF/lib ( in the cocoon directory of course)

1.2 Here are extracts of  what you have to add in cocoon.xconf and 
sitemap.xmap:

# cocoon.xconf 
<component
    role="org.apache.cocoon.components.xslt.XSLTProcessor/Saxon"
    class="org.apache.cocoon.components.xslt.XSLTProcessorImpl"
    logger="core.xslt-processor">
  <parameter name="use-store" value="true"/>
  <parameter name="incremental-processing" value="false"/>
  <parameter name="transformer-factory"
value="com.icl.saxon.TransformerFactoryImpl"/>
</component>

# sitemap.xmap
<map:transformer name="xslt-saxon" pool-grow="2" pool-max="32" pool-min="8"
       src="org.apache.cocoon.transformation.TraxTransformer">
    <use-request-parameters>false</use-request-parameters>
    <use-browser-capabilities-db>false</use-browser-capabilities-db>

<xslt-processor-role>org.apache.cocoon.components.xslt.XSLTProcessor/Saxon</xslt-processor-role>

  </map:transformer>"

</citationFromAMail.SeeTheReferences>

in yor pipeline when you do a transformation from docbook to pdf you will use 
something similar:

<map:match pattern="*.pdf">
	<map:generate src="{1}.docbook"/>
	<map:tranform type="xslt-saxon" src="WhereverYouPutIt/fo/docbook.xsl"/>
	<map:serialize type="fo2pdf"/>
</map:match>
<map:match pattern="*.html">
	<map:generate src="{1}.docbook"/>
	<map:tranform type="xslt-saxon" src="WhereverYouPutIt/html/docbook.xsl"/>
	<map:serialize type="fo2pdf"/>
</map:match>

In this way if you will leave xslt as the default type of transformation, you 
will use use xalan and all his xsp capabilities for all the the other cocoon 
functions.

2. Renaming saxon.jar z-saxon.jar (I am not sure that is necessary but in this 
way works)

3. Modifying Saxon to make it use xerces instead of aelfred as parser

Change the content of
META-INF/services/javax.xml.parsers.SAXParserFactory from
com.icl.saxon.aelfred.SAXParserFactoryImpl to
org.apache.xerces.jaxp.SAXParserFactoryImpl. That tells
Saxon to use xerces instead of aelfred as parser.

Don't be worried it is not so complicated: you have to extract the file 
(javax.xml.parsers.SAXParserFactory) from saxon.jar edit it (is a text file) 
and to put it again in the same place in saxon.jar

Conclusion:
I must say that the Saxon and xalan problems in using Norman Walsh's 
stylesheets should be addressed inside cocoon developing activity. It 
shouldn't be so hard to make docbook to pdf transformation work.
Comments are welcome.

Gabriele Domenichini

References:
To use different xslt processors or different behaviour of the same:
http://xml.apache.org/cocoon/snippet/snippet-xslt-options.html

To use saxon in alternative the mail from which I took the solution is: 
(http://www.mail-archive.com/cocoon-users@xml.apache.org/msg15968.html) which 
tell exactly what to do:

To change the behavior of saxon there's a mail 
(http://sources.redhat.com/ml/docbook-apps/2002-q2/msg00397.html) which 
explain three workaround. I have choosen the third


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message