You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Andrzej Jan Taramina <an...@chaeron.com> on 2004/03/24 03:52:19 UTC

Using Saxon 7.9 with Cocoon?

I've been trying to switch our Cocoon (2.1.4) application from using the 
latest Xalan over to using Saxon 7.9 to try and improve XSLT performance.

The problem I am running into is that I keep getting a Saxon exception being 
thrown saying that the Saxon DOM implementation cannot be updated (it's read-
only).

Has anyone managed to get around this and get Cocoon 2.1.4 working using 
Saxon 7.9 as the default XSLT processor?

If so, how did you do this?  Did you replace the Saxon DOM implementation 
(and if so, how)?

Thanks!

Andrzej Jan Taramina
Chaeron Corporation: Enterprise System Solutions
http://www.chaeron.com


Re: Using Saxon 7.9 with Cocoon?

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Sylvain Wallez wrote:

> Andrzej Jan Taramina wrote:
>
>> I've been trying to switch our Cocoon (2.1.4) application from using 
>> the latest Xalan over to using Saxon 7.9 to try and improve XSLT 
>> performance.
>>
>> The problem I am running into is that I keep getting a Saxon 
>> exception being thrown saying that the Saxon DOM implementation 
>> cannot be updated (it's read-
>> only).
>>
>> Has anyone managed to get around this and get Cocoon 2.1.4 working 
>> using Saxon 7.9 as the default XSLT processor?
>

Saxon 7.9 has different XPath API - you'll need CVS version of 
excalibur-xmlutils.


>> If so, how did you do this?  Did you replace the Saxon DOM 
>> implementation (and if so, how)?
>>  
>>
>
> I remember having such problems with older versions of Saxon, and the 
> culprit was the AElfred parser that comes bundled with Saxon which is 
> limited to saxon's needs (hence why it's read-only).
>
> Two trick solve the problem:
> - remove the META-INF/services/java.xml.parsers.* files in the saxon jar
> - rename saxon.jar to zsaxon.jar so that it comes after xerces in the 
> classpath (highly servlet engine dependent though).


One more trick:
 - Do not attempt to modify Saxon's DOM. Works for me.


Vadim



Re: Using Saxon 7.9 with Cocoon?

Posted by Bruno Dumon <br...@outerthought.org>.
On Wed, 2004-03-24 at 15:16, Andrzej Jan Taramina wrote:
> Sylvain:
> 
> X-posted to the Saxon list as well.....
> 
> > I remember having such problems with older versions of Saxon, and the 
> > culprit was the AElfred parser that comes bundled with Saxon which is 
> > limited to saxon's needs (hence why it's read-only).
> 
> The latest version of Saxon (7.9) does not include AElfred any more.  AElfred 
> is now a separate download, which I am not using, so that part is not an 
> issue.
> 
> > Two trick solve the problem:
> > - remove the META-INF/services/java.xml.parsers.* files in the saxon jar
> 
> With AElfred not included, this entry is no longer in the jar file.  However, 
> there is a java.xml.transform.TransformerFactory entry in META-INF/services 
> with the value of "net.sf.saxon.TransformerFactoryImpl".  I think this entry 
> is the one that causes the Saxon dom to be used.
> 
> > - rename saxon.jar to zsaxon.jar so that it comes after xerces in the 
> > classpath (highly servlet engine dependent though).
> 
> Already did that, but with the latest versions (and Tomcat), it still seems 
> that you need the Xalan jar file ahead of the Saxon one, or the Saxon read-
> only DOM still gets selected.
> 
> It looks to me that it's the java.xml.transform.TransformerFactory entry in 
> META-INF/services that controls this.  With the Xalan jar first the value 
> points to the Xalan implementation of the TransformerFactory implementation, 
> which in turn grabs the Apache DOM implementation instead of the troublesome 
> Saxon one.  The issue with doing this (even though it works...yay!) is that 
> I'm not sure how much of Xalan versus Saxon is being used for XSL 
> transformations when you use the Xalan transformer factory reference.
> 
> Any insight?

throw out the whole META-INF directory from the saxon jar.

Cocoon uses the transformer stuff also for other things, like going from
SAX to DOM (in the DOMBuilder class) or from SAX to stream (in the
serializers).

For the XSLT processor, the transformer factory class name is specified
in the cocoon.xconf, so the things in META-INF aren't relevant for that.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


RE: [saxon] Re: Using Saxon 7.9 with Cocoon?

Posted by Michael Kay <mh...@mhk.me.uk>.
# 
# X-posted to the Saxon list as well.....
# 
# > I remember having such problems with older versions of 
# Saxon, and the 
# > culprit was the AElfred parser that comes bundled with 
# Saxon which is 
# > limited to saxon's needs (hence why it's read-only).

AElfred is a SAX parser only, it does not include a DOM, so this is quite
irrelevant.
# 
# It looks to me that it's the 
# java.xml.transform.TransformerFactory entry in 
# META-INF/services that controls this.  With the Xalan jar 
# first the value points to the Xalan implementation of the 
# TransformerFactory implementation, which in turn grabs the 
# Apache DOM implementation instead of the troublesome Saxon 
# one.  The issue with doing this (even though it works...yay!) 
# is that I'm not sure how much of Xalan versus Saxon is being 
# used for XSL transformations when you use the Xalan 
# transformer factory reference.

TransformerFactory identifies which XSLT processor you are using, it has
nothing to do with the DOM implementation. If you do what you're suggesting,
you'll be running Xalan.
# 
# Any insight?
# 

You haven't given us the most important pieces of information: where is the
"troublesome" DOM created, what role does it play in the transformation
(source tree? result tree? temporary tree?), and do you want to update it
before, during, or after the transformation?

Michael Kay


Re: Using Saxon 7.9 with Cocoon?

Posted by Andrzej Jan Taramina <an...@chaeron.com>.
Sylvain:

X-posted to the Saxon list as well.....

> I remember having such problems with older versions of Saxon, and the 
> culprit was the AElfred parser that comes bundled with Saxon which is 
> limited to saxon's needs (hence why it's read-only).

The latest version of Saxon (7.9) does not include AElfred any more.  AElfred 
is now a separate download, which I am not using, so that part is not an 
issue.

> Two trick solve the problem:
> - remove the META-INF/services/java.xml.parsers.* files in the saxon jar

With AElfred not included, this entry is no longer in the jar file.  However, 
there is a java.xml.transform.TransformerFactory entry in META-INF/services 
with the value of "net.sf.saxon.TransformerFactoryImpl".  I think this entry 
is the one that causes the Saxon dom to be used.

> - rename saxon.jar to zsaxon.jar so that it comes after xerces in the 
> classpath (highly servlet engine dependent though).

Already did that, but with the latest versions (and Tomcat), it still seems 
that you need the Xalan jar file ahead of the Saxon one, or the Saxon read-
only DOM still gets selected.

It looks to me that it's the java.xml.transform.TransformerFactory entry in 
META-INF/services that controls this.  With the Xalan jar first the value 
points to the Xalan implementation of the TransformerFactory implementation, 
which in turn grabs the Apache DOM implementation instead of the troublesome 
Saxon one.  The issue with doing this (even though it works...yay!) is that 
I'm not sure how much of Xalan versus Saxon is being used for XSL 
transformations when you use the Xalan transformer factory reference.

Any insight?

Thanks!


Andrzej Jan Taramina
Chaeron Corporation: Enterprise System Solutions
http://www.chaeron.com


Re: Using Saxon 7.9 with Cocoon?

Posted by Sylvain Wallez <sy...@apache.org>.
Andrzej Jan Taramina wrote:

>I've been trying to switch our Cocoon (2.1.4) application from using the 
>latest Xalan over to using Saxon 7.9 to try and improve XSLT performance.
>
>The problem I am running into is that I keep getting a Saxon exception being 
>thrown saying that the Saxon DOM implementation cannot be updated (it's read-
>only).
>
>Has anyone managed to get around this and get Cocoon 2.1.4 working using 
>Saxon 7.9 as the default XSLT processor?
>
>If so, how did you do this?  Did you replace the Saxon DOM implementation 
>(and if so, how)?
>  
>

I remember having such problems with older versions of Saxon, and the 
culprit was the AElfred parser that comes bundled with Saxon which is 
limited to saxon's needs (hence why it's read-only).

Two trick solve the problem:
- remove the META-INF/services/java.xml.parsers.* files in the saxon jar
- rename saxon.jar to zsaxon.jar so that it comes after xerces in the 
classpath (highly servlet engine dependent though).

Hope this helps.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }