You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Steffen Stundzig <st...@smb-tec.com> on 2001/01/26 10:45:50 UTC

[C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Hi Ovidiu,

/**
 * @author: Ovidiu Predescu <ov...@cup.hp.com> 
 * @date: Thu, 25 Jan 2001 08:36:24 -0800
 */
> On Thu, 25 Jan 2001 17:04:36 +0100, Steffen Stundzig <st...@smb-tec.com> 
> wrote:
> 
> Steffen, could you please post your changes to the mailing list?

here are my way to get Cocoon 1.8.1 working with Saxon6.1.
I've tested it with the latest update from the cocoon CVS, but it should
work also with older versions.

1. Put the attached SAXONTransformer into the Cocoon source tree.
2. [Patch] Put the initialization of the 'store' actor in the 
   Cocoon Engine before the initialization of the 'transformer'. This
   is needed, because the transformer needs the 'store' for caching.
3. Modify the part 'XSLT Transformer' in your 'cocoon.properties' file, 
   to use the SAXONTransformer. See my file snippet for details.
4. Put the saxon.jar in your 'cocoon' classpath and recompile cocoon.
5. Put the saxon.jar in your 'project' classpath, start your servlet
   engine and have fun. :-)

You can found the saxon.jar at 
   http://users.iclway.co.uk/mhkay/saxon/
but the current version 6.1 has a small bug in the sourcefile
   com.icl.saxon.StandardURIResolver.java line 112 and 113.
There an URI with "file:/" is constructed, but it must only be "file:". 
Michael Kay has applied this patch into his original source tree, but
his hasn't updated the download package. So you can download the
saxon package from the URL above, fix the bug and recompile them or
you could use my precompiled saxon version at 
   http://www.stundzig.de/saxon6.1_unofficial.jar (ca: 550kB).

Hints and criticism are very welcome. This description comes WITHOUT ANY
WARRANTY. :-)


Best regards
	Steffen...


-- 
______________________________________________________________________
Steffen Stundzig                            mailto:steffen@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com




RE: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Donald Ball <ba...@webslingerZ.com>.
On Mon, 29 Jan 2001, Martin Sevigny wrote:

> OK, I've got it straight with a dirty hack.
>
> Here's what works on NT (and Linux):
>
> - Cocoon 1.8.2 CVS January 26th
> - Saxon 6.1 from Steffen (posted earlier: http://www.stundzig.de/saxon6.1_unofficial.jar (ca: 550kB))
> - SaxonTransformer.java from Steffen or CVS with this little modification:
>
> Add:
>
> if ( sheetBase != null )
> {
>   File f = new File(sheetBase);
>   sheetBase = f.toURL().toString();
> }

can you send me a cvs diff of this patch? it was ambiguous to me where
this should go.

- donald


RE: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Martin Sevigny <se...@ajlsm.com>.
Steffen and all others wanting to use Saxon with Cocoon,

> aah. Now it's clear to me, I think. :-) You don't use the latest 
> cocoon from
> CVS? There is a bug in org.apache.cocoon.processor.xsp.XSPProcessor.
> The xsp stylesheet is initialized with null and therefore saxon 
> throws this exception. I've send the patch at 01/01/19 to cocoon-dev and
> in the current CVS it's fixed.

OK, I've got it straight with a dirty hack.

Here's what works on NT (and Linux):

- Cocoon 1.8.2 CVS January 26th
- Saxon 6.1 from Steffen (posted earlier: http://www.stundzig.de/saxon6.1_unofficial.jar (ca: 550kB))
- SaxonTransformer.java from Steffen or CVS with this little modification:

Add: 

if ( sheetBase != null )
{
  File f = new File(sheetBase);
  sheetBase = f.toURL().toString();
}

before the DOMSource construction (in javax.xml.transform.Transformer).

This will make sure that Saxon receives a base URI in URL form, such as "file:/xxx". And now it works. There is probably a more elegant way and more robust, but it's for another time. It works under Linux too, by the way.

A few advices to all of you trying to make Saxon work with Cocoon:

- Saxon is in general less forgiving about errors in XSLT than Xalan. Some XSLT files can work with Xalan but not with Saxon, so make sure you test your XSLT files carefully.

- I've tried to use the ESQL taglib from Cocoon 1.8.2 with Saxon, and it failed to compile the logicsheet! I've not tested much, because I had to change it anyway, but it looked like one of these errors due to the lack of forgiveness of Saxon

Now Saxon works, and my app is really quicker.

Thank's a lot for your help,

Martin Sévigny


Re: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Steffen Stundzig <st...@smb-tec.com>.
Hi Martin,

/**
 * @author: "Martin Sevigny" <se...@ajlsm.com> 
 * @date: Fri, 26 Jan 2001 18:42:57 +0100
 */
> Steffen,
> 
> That's what I was getting. I've thrown away all my compiled XSP pages and now it can't compile my logicsheets, I get this stack trace:
> 
> java.lang.NullPointerException: URI may not be null

aah. Now it's clear to me, I think. :-) You don't use the latest cocoon from
CVS? There is a bug in org.apache.cocoon.processor.xsp.XSPProcessor.
The xsp stylesheet is initialized with null and therefore saxon 
throws this exception. I've send the patch at 01/01/19 to cocoon-dev and
in the current CVS it's fixed.

The patch was:

Index: src/org/apache/cocoon/processor/xsp/XSPProcessor.java
 ===================================================================
 RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/processor/xsp/XSPProcessor.java,v
 retrieving revision 1.37
 diff -r1.37 XSPProcessor.java
 169d168
 <             XSPLogicsheet logicsheet = new XSPLogicsheet(transformer, parser, null);
 182a182,185
 > 
 >             XSPLogicsheet logicsheet = new XSPLogicsheet(transformer, parser, 
 >                     this.getClass().getResource(logicsheetName).toString()); 
 >                     

Regards
	Steffen...
-- 
______________________________________________________________________
Steffen Stundzig                            mailto:steffen@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com




RE: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Martin Sevigny <se...@ajlsm.com>.
Steffen,

> Do you receive an error from Saxon such as 
>    javax.xml.transform.TransformerConfigurationException: 
>              Failed to compile stylesheet. 1 error detected.

That's what I was getting. I've thrown away all my compiled XSP pages and now it can't compile my logicsheets, I get this stack trace:

java.lang.NullPointerException: URI may not be null
	at com.icl.saxon.tree.DocumentImpl.setSystemId(DocumentImpl.java:123)
	at com.icl.saxon.tree.TreeBuilder.startDocument(TreeBuilder.java:89)
	at com.icl.saxon.output.ProxyEmitter.startDocument(ProxyEmitter.java:61)
	at com.icl.saxon.Stripper.startDocument(Stripper.java:109)
	at com.icl.saxon.ContentEmitter.startDocument(ContentEmitter.java:61)
	at com.icl.saxon.DOMDriver.parse(DOMDriver.java:190)
	at com.icl.saxon.DOMDriver.parse(DOMDriver.java:162)
	at com.icl.saxon.Builder.build(Builder.java:252)
	at com.icl.saxon.PreparedStyleSheet.prepare(PreparedStyleSheet.java:107)
	at com.icl.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:119)
	at org.apache.cocoon.transformer.SAXONTransformer.getTransformer(SAXONTransformer.java:310)
	at org.apache.cocoon.transformer.SAXONTransformer.transform(SAXONTransformer.java, Compiled Code)
	at org.apache.cocoon.processor.xsp.XSPLogicsheet.apply(XSPLogicsheet.java:102)
	at org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java, Compiled Code)
	at org.apache.cocoon.Engine.handle(Engine.java, Compiled Code)
	at org.apache.cocoon.Cocoon.service(Cocoon.java:167)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java, Compiled Code)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
	at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
	at java.lang.Thread.run(Unknown Source)

When SaxonTransformer is called, the sheetBase property is correctly set to "file:/d:/..." up to the logicsheet.

> or occurs this error before Saxon is invoked? 
> It looks like an Windows specific error on method getResource() in the 
> org.apache.cocoon.processor.xslt.XSLTProcessor class, because there was  
> created an URL based on the method Utils.getRootPath(). I class 
> Utils I found the
> following comment:
> 
>  // FIXME (SM): I have _no_absolute_idea_ how much this is 
> portable. The whole
>  // architecture should be based on URL rather than Files to allow the 
>  // use of Servlet 2.2 getResource() to void calling such nasty methods
>  // but for now, well, it's the best I can do :(
>  return request.getRealPath("/");
> 
> Any ideas to fix it?

Not for now, but I don't think my problem is there...

Thank's a lot again,

Martin


Re: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Steffen Stundzig <st...@smb-tec.com>.
Hi Martin,

/**
 * @author: "Martin Sevigny" <se...@ajlsm.com> 
 * @date: Fri, 26 Jan 2001 17:53:58 +0100
 */
> Steffen,
> 
> > > Error on xsl:import on line ...
> > >  d:\currentdir\d:\path_to_xsl\file_to_import.xsl (file not found)
> > 
> > do you wrote down the absolut filename with the complete path in your
> > <xsl:import> element?
> > 
> > If so, insert a "file:/" before the path and test it?
> 
> The calling stylesheet is in d:\path_to_xsl\, and the called stylesheet too.
> 
> In Xalan:
> 
> <xsl:import href="file_to_import.xsl"/> works
> 
> In Saxon:
> 
> <xsl:import href="file_to_import.xsl"/> does'nt work
> <xsl:import href="d:\path_to_xsl\file_to_import.xsl"/> does'nt work
> <xsl:import href="file:/d:\path_to_xsl\file_to_import.xsl"/> works
> 
> I've checked the sheetBase parameter passed to SaxonTransformer.getTransformer, and it is correctly set to the calling stylesheet, in the form "d:\path_to_xsl\...".
> 
> It can compile logicsheets neither, but this time the sheetBase property is set to something beginning with "file:/d:/...".
> 
> Any other idea? Trace doesn't help, my stylesheet is never compiled.

Do you receive an error from Saxon such as 
   javax.xml.transform.TransformerConfigurationException: 
             Failed to compile stylesheet. 1 error detected.

or occurs this error before Saxon is invoked? 
It looks like an Windows specific error on method getResource() in the 
org.apache.cocoon.processor.xslt.XSLTProcessor class, because there was  
created an URL based on the method Utils.getRootPath(). I class Utils I found the
following comment:

 // FIXME (SM): I have _no_absolute_idea_ how much this is portable. The whole
 // architecture should be based on URL rather than Files to allow the 
 // use of Servlet 2.2 getResource() to void calling such nasty methods
 // but for now, well, it's the best I can do :(
 return request.getRealPath("/");

Any ideas to fix it?

Regards
	Steffen...

-- 
______________________________________________________________________
Steffen Stundzig                            mailto:steffen@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com




RE: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Martin Sevigny <se...@ajlsm.com>.
Steffen,

> > Error on xsl:import on line ...
> >  d:\currentdir\d:\path_to_xsl\file_to_import.xsl (file not found)
> 
> do you wrote down the absolut filename with the complete path in your
> <xsl:import> element?
> 
> If so, insert a "file:/" before the path and test it?

The calling stylesheet is in d:\path_to_xsl\, and the called stylesheet too.

In Xalan:

<xsl:import href="file_to_import.xsl"/> works

In Saxon:

<xsl:import href="file_to_import.xsl"/> does'nt work
<xsl:import href="d:\path_to_xsl\file_to_import.xsl"/> does'nt work
<xsl:import href="file:/d:\path_to_xsl\file_to_import.xsl"/> works

I've checked the sheetBase parameter passed to SaxonTransformer.getTransformer, and it is correctly set to the calling stylesheet, in the form "d:\path_to_xsl\...".

It can compile logicsheets neither, but this time the sheetBase property is set to something beginning with "file:/d:/...".

Any other idea? Trace doesn't help, my stylesheet is never compiled.

Thanks,

Martin Sévigny


Re: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Steffen Stundzig <st...@smb-tec.com>.
Hi Martin,

/**
 * @author: "Martin Sevigny" <se...@ajlsm.com> 
 * @date: Fri, 26 Jan 2001 17:27:09 +0100
 */
> Steffen,
> 
> > You get an error message from cocoon? 
> 
> I get this:
> 
> Error on xsl:import on line ...
>  d:\currentdir\d:\path_to_xsl\file_to_import.xsl (file not found)

do you wrote down the absolut filename with the complete path in your
<xsl:import> element?

If so, insert a "file:/" before the path and test it?

Hope that helps
	Steffen... 

-- 
______________________________________________________________________
Steffen Stundzig                            mailto:steffen@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com




RE: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Martin Sevigny <se...@ajlsm.com>.
Steffen,

> > Thank's for the contribution. Just a question: have you tested 
> it with <xsl:import>, <xsl:include> or document() statements in 
> XSLT? I'm having trouble with stylesheets containing them, and 
> before going too deep I would like to know if it's a known limitation.
> > 
> > Running those stylesheet from the command line works fine, but 
> not with Cocoon...
> > 
> you are using the original unpatched saxon package from michael 
> kay's homepage?

No, yours, I just doublechecked.

> You get an error message from cocoon? 

I get this:

Error on xsl:import on line ...
 d:\currentdir\d:\path_to_xsl\file_to_import.xsl (file not found)

As you can see, it appends the current dir to the complete path of the XSL it tries to import.

I'm on Windows NT, could it be the problem?

Thank's for your help, I've seen that Saxon is around 30% faster than Xalan for my application, I would like to make it work.

Martin Sévigny


Re: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Steffen Stundzig <st...@smb-tec.com>.
Hi Martin,

/**
 * @author: "Martin Sevigny" <se...@ajlsm.com> 
 * @date: Fri, 26 Jan 2001 16:41:17 +0100
 */
> Steffen,
> 
> Thank's for the contribution. Just a question: have you tested it with <xsl:import>, <xsl:include> or document() statements in XSLT? I'm having trouble with stylesheets containing them, and before going too deep I would like to know if it's a known limitation.
> 
> Running those stylesheet from the command line works fine, but not with Cocoon...
> 
you are using the original unpatched saxon package from michael kay's homepage?
You get an error message from cocoon? 
It could be a good choice to enable 'trace' of your saxon transformer.
See the cocoon.properties attached in my email this morning. 

I could use all of your statements above with relative filenames such as 
   <xsl:import href="../intranet.xsl"/> or <xsl:include href="../file.xsl"/>

and also the method document() e.g. "document('commands.xml')". 
The file commands.xml resists in the same directory as the stylesheet 
that includes it. 

Absolut URL's that starts with "file://" should also work.

Regards
	Steffen...

-- 
______________________________________________________________________
Steffen Stundzig                            mailto:steffen@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com




Re: [C1][Patch] Saxon and Cocoon1.8.1 [Was:Re: PERFORMANCE PROBLEM!]

Posted by Donald Ball <ba...@webslingerZ.com>.
i added this to cvs. thanks!

- donald