Dear Cocoonists,
I'm getting a strange error when using Saxon with Cocoon.
Versions: Tomcat 4.1, Cocoon 2.1.2, Saxon 7.9
Summary of problem: I get an error "The Saxon DOM cannot be updated"
at a point in the pipeline where Saxon isn't supposed to be involved.
I have Saxon associated with the "xslt-saxon" transformer type,
as shown in my sitemap:
<map:components>
<map:generators default="file"/>
<map:transformers default="xslt">
<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>saxon</xslt-processor-role>
</map:transformer>
</map:transformers>
xslt (Xalan) is defined as the default transformer in the Cocoon sitemap:
<map:transformers default="xslt">
<!-- NOTE: This is the default XSLT processor. -->
<map:transformer logger="sitemap.transformer.xslt" name="xslt" pool-grow="2"
pool-max="32"
pool-min="8" src="org.apache.cocoon.transformation.TraxTransformer">
<use-request-parameters>false</use-request-parameters>
<use-session-parameters>false</use-session-parameters>
<use-cookie-parameters>false</use-cookie-parameters>
<xslt-processor-role>xalan</xslt-processor-role>
</map:transformer>
Incidentally, this is how Saxon is set up in my cocoon.xconf:
<component logger="core.xslt-processor"
role="org.apache.excalibur.xml.xslt.XSLTProcessor/saxon"
class="org.apache.excalibur.xml.xslt.XSLTProcessorImpl">
<parameter name="use-store" value="true"/>
<parameter name="transformer-factory"
value="net.sf.saxon.TransformerFactoryImpl"/>
<parameter name="incremental-processing" value="false"/>
</component>
That part seems to be working fine.
The problem scenario is this.
I have a pipeline as follows:
<map:match pattern="test-name-index/*/*/*">
<map:generate src="sources/Language-name-index{3}.xml" label="raw" />
<map:transform src="transforms/name-index-step1-xsl{2}.xsl" type="xslt-saxon"
label="raw1"
/>
<map:transform src="transforms/add-source-write.xsl" type="xslt" label="raw2">
<map:parameter name="output-file" value="Language-name-index{3}-grouped.xml"
/>
</map:transform>
<map:transform type="write-source" />
<map:serialize type="xml" />
</map:match>
(The first * in the match pattern was originally intended to let me
parameterize the transformer type of the first transformer, e.g. to
switch between xslt and xslt-saxon. However the sitemap processor
complained that "{1}" wasn't a valid transformer type. This is a side
issue but if anyone has an answer I'd be interested.)
The idea is to take data from the XML source file, perform a grouping
transformation on it using the name-index-step1-xsl1.xsl stylesheet
using Saxon, wrap <source:write> markup around the result, and then
pass the whole through the write-source processor to send it to a file.
I use ?cocoon-view=raw, raw1, raw2 to check the progress at various points
in the pipeline.
When I run the URL "test-name-index/xslt-saxon/1/Tiny?cocoon-view=raw2",
the pipeline runs successfully up to raw2, showing me the desired XML
wrapped in <source:write> markup. However, if I take off the cocoon-view
parameter, allowing the whole pipeline to run, I get the error:
Failed to execute pipeline.
org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
java.lang.RuntimeException:
java.lang.UnsupportedOperationException: The Saxon DOM cannot be updated
Looking in the error.log, I find:
FATAL_E (2004-07-30) 08:54.16:200 [core.xslt-processor] (/cvsmount/ethnologue/
test-name-index/xslt-saxon/1/Tiny) Thread-9/TraxErrorHandler: Error in TraxTrans
former: file:/C:/Program%20Files/Apache%20Group/Tomcat%204.1/./../cocoon/./cvsmo
unt/ethnologue/transforms/add-source-write.xsl; Line 14; Column 21;
; SystemID: file:/C:/Program%20Files/Apache%20Group/Tomcat%204.1/./../cocoon/./c
vsmount/ethnologue/transforms/add-source-write.xsl; Line#: 14; Column#: 21
javax.xml.transform.TransformerException: java.lang.UnsupportedOperationExceptio
n: The Saxon DOM cannot be updated
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
ansformerImpl.java:2341)
So the error is reported in add-source-write.xsl -- the stylesheet that was
working fine when I used cocoon-view=raw2. Moreover, add-source-write.xsl
is done using xslt, not xslt-saxon; so why a Saxon error at all?
(In fact, if I change "xslt-saxon" to "xslt" in the above pipeline,
I still get the same error. Is it possible that Saxon is being used
even where type="xslt"? If so, how would I know it and how would I
fix it?)
Thirdly, I can't see that any attempt is being made to update a DOM.
Does it mean add-source-write.xsl is attempting to modify a DOM output
by Saxon's processing of name-index-step1-xsl1.xsl?
Here is add-source-write.xsl, with the "offending" line 14 marked:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:source="http://apache.org/cocoon/source/1.0">
<xsl:output method="xml" version="1" indent="yes" encoding="utf-8" />
<xsl:param name="output-file" select="/.." />
<xsl:template match="/">
<source:write>
<source:source>context:/cvsmount/ethnologue/<xsl:value-of
select="$output-file"/></source:source>
<source:fragment><xsl:copy-of select="*" /></source:fragment><!--line 14-->
</source:write>
</xsl:template>
</xsl:stylesheet>
Here is the output after add-source-write.xsl, when the above pipeline is
used with cocoon-view=raw2:
<source:write xmlns:source="http://apache.org/cocoon/source/1.0">
<source:source>context:/cvsmount/ethnologue/Language-name-indexTiny-grouped.xml</source:source>
<source:fragment>
<Language-name-index xmlns:od="urn:schemas-microsoft-com:officedata">
<entry name="Aqua">
<record>
<PRINT_NAME>Aqua</PRINT_NAME>
<KEY1>Aqua</KEY1>
<Type>alt. dial.</Type>
<Name>Ejagham</Name>
<X_XXX>ETU</X_XXX>
<Key2>alt. dial.Ejagham.ETU</Key2>
<Key3>Africa.Cameroon</Key3>
<COUNTRY_CODE>CM</COUNTRY_CODE>
</record>
<record>
<PRINT_NAME>Aqua</PRINT_NAME>
<KEY1>Aqua</KEY1>
<Type>alt. dial.</Type>
<Name>Ejagham</Name>
<X_XXX>ETU</X_XXX>
<Key2>alt. dial.Ejagham.ETU</Key2>
<Key3>Africa.Nigeria</Key3>
<COUNTRY_CODE>NG</COUNTRY_CODE>
</record>
</entry>
<entry name="Ara">
<record>
<PRINT_NAME>Ara</PRINT_NAME>
<KEY1>Ara</KEY1>
<Type>alt.</Type>
<Name>Aari</Name>
<X_XXX>AIZ</X_XXX>
<Key2>alt.Aari.AIZ</Key2>
<Key3>Africa.Ethiopia</Key3>
<COUNTRY_CODE>ET</COUNTRY_CODE>
</record>
<record>
<PRINT_NAME>Ara</PRINT_NAME>
<KEY1>Ara</KEY1>
<Type>alt.</Type>
<Name>Arh�</Name>
<X_XXX>ARN</X_XXX>
<Key2>alt.Arh�.ARN</Key2>
<Key3>Pacific.New Caledonia</Key3>
<COUNTRY_CODE>NC</COUNTRY_CODE>
</record>
<record>
<PRINT_NAME>Ara</PRINT_NAME>
<KEY1>Ara</KEY1>
<Type>alt.</Type>
<Name>W�ra</Name>
<X_XXX>TCI</X_XXX>
<Key2>alt.W�ra.TCI</Key2>
<Key3>Pacific.Papua New Guinea</Key3>
<COUNTRY_CODE>PG</COUNTRY_CODE>
</record>
</entry>
</Language-name-index>
</source:fragment>
</source:write>
For completeness, I'll show name-index-step1-xsl1.xsl, though it doesn't
seem relevant to the error:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- The maximum number of records for a given name. At present there are 108
records for
English-->
<xsl:variable name="maxRecords">20</xsl:variable>
<xsl:template match="/Language-name-index">
<xsl:copy>
<xsl:for-each select="*">
<xsl:if test="position() = 1 or KEY1 !=
preceding-sibling::*[1]/KEY1">
<xsl:variable name="key" select="KEY1"/>
<xsl:element name="entry">
<xsl:attribute
name="name"><xsl:value-of select="PRINT_NAME"/></xsl:attribute>
<xsl:call-template
name="copy-records-with-same-key">
<xsl:with-param name="record"
select="."/>
</xsl:call-template>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:copy>
</xsl:template>
<xsl:template name="copy-records-with-same-key">
<xsl:param name="record"/>
<xsl:copy-of select="$record"/>
<xsl:if test="$record/KEY1 = $record/following-sibling::*[1]/KEY1">
<xsl:call-template name="copy-records-with-same-key">
<xsl:with-param name="record"
select="$record/following-sibling::*[1]"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
I read somewhere of somebody else having the problem that when they
tried using Saxon at all, it got used everywhere. Is this one of
those things where I have to rename saxon7.jar to zsaxon7.jar
so it comes after xalan in the classpath??
Thanks for any help...
Lars
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]