You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gabriele Domenichini <ga...@fastmail.fm> on 2002/09/28 10:34:36 UTC

Cocoon 2, Docbook and Norman Walsh's Stylesheets

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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Cocoon 2, Docbook and Norman Walsh's Stylesheets

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Vadim Gritsenko wrote:
> 3. I might be mistaken, but I do not see why Saxon needs to be modified. 
> Cocoon  by default will use Xerces parser, not Aelfred, and from Saxon 
> only XSLT engine will be used.
It depends. Saxon has the service for XML parsers set to AElfred, and if
the saxon.jar is in the class path before XercesImpl.jar and if cocoon.xconf
does specify a JAXP parser instead XercesParser so that the service definition
is used, then AEfred may be actually used as SAX parser. Nobody will notice
because Xerces is still used as parser for DOM documents, until someone wants
the parser to validate source documents ...

J.Pietschmann


---------------------------------------------------------------------
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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Cocoon 2, Docbook and Norman Walsh's Stylesheets

Posted by Gabriele Domenichini <ga...@fastmail.fm>.
Alle 15:35, lunedì 30 settembre 2002, Vadim Gritsenko ha scritto:
> Gabriele,
>
> Some comments.
>
> 1. Saxon does *not* support incremental processing, thus:
> <parameter name="incremental-processing" value="false"/>
> effectively does nothing.
Thank you, I didn't know

> 2. Saxon works with XSP. I do have an app with Saxon only (no Xalan) and
> XSPs. Never had any problem. The only problem is you still need
> Xalan.jar if you are using XPath component.

I do have Xalan.jar in my classpath and I get error if don't say in the 
sitemap to use it instead of saxon.

>
> 3. I might be mistaken, but I do not see why Saxon needs to be modified.
> Cocoon  by default will use Xerces parser, not Aelfred, and from Saxon
> only XSLT engine will be used.
>

I read this information on 
http://sources.redhat.com/ml/docbook-apps/2002-q2/msg00397.html and after the 
modification it works. It could be a question of versioning. I use cocoon 
2.0.3 Saxon 6.5.2 and  xalan 2.4.0. Anyway I'm trying to write a snippet and 
I'll report your observations. 

---------------------------------------------------------------------
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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Cocoon 2, Docbook and Norman Walsh's Stylesheets

Posted by Vadim Gritsenko <va...@verizon.net>.
Gabriele,

Some comments.

1. Saxon does *not* support incremental processing, thus:
<parameter name="incremental-processing" value="false"/>
effectively does nothing.

2. Saxon works with XSP. I do have an app with Saxon only (no Xalan) and 
XSPs. Never had any problem. The only problem is you still need 
Xalan.jar if you are using XPath component.

3. I might be mistaken, but I do not see why Saxon needs to be modified. 
Cocoon  by default will use Xerces parser, not Aelfred, and from Saxon 
only XSLT engine will be used.


Vadim




Gabriele Domenichini wrote:

>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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Cocoon 2, Docbook and Norman Walsh's Stylesheets

Posted by Gabriele Domenichini <ga...@fastmail.fm>.
Alle 12:38, lunedì 30 settembre 2002, Diana Shannon ha scritto:
> > 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

> Thanks Gabriele!
>
> I know you already spent a lot of time on this issue, but (please,
> please) how about contributing a patch (snippet) of this doc for the
> cocoon cvs/web site or perhaps adding it to CocoonWiki?
>
> -- Diana
>

No. I thank you and all the people who has answered to the mail and I'll try 
to set it up as soon as I can. if not tonight (now for me it's 8 pm) maybe 
tomorrow morning. Just please go on also making critics and I' ltake them in 
consideration in writing the snippet.

---------------------------------------------------------------------
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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Cocoon 2, Docbook and Norman Walsh's Stylesheets

Posted by Gabriele Domenichini <ga...@fastmail.fm>.
Alle 12:38, lunedì 30 settembre 2002, Diana Shannon ha scritto:
>..
> I know you already spent a lot of time on this issue, but (please,
> please) how about contributing a patch (snippet) of this doc for the
> cocoon cvs/web site or perhaps adding it to CocoonWiki?
>
Added snippett in cocoonWiki. I will correct it tomorrow. Everyone is invited 
to modify it.
I'm preparing the snippet to send to apache.org by bugzilla.
Thanks again
Gabriele Domenichini

---------------------------------------------------------------------
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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Cocoon 2, Docbook and Norman Walsh's Stylesheets

Posted by Diana Shannon <sh...@apache.org>.
> 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.

Thanks Gabriele!

I know you already spent a lot of time on this issue, but (please, 
please) how about contributing a patch (snippet) of this doc for the 
cocoon cvs/web site or perhaps adding it to CocoonWiki?

-- Diana


---------------------------------------------------------------------
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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>