You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by ma...@netscape.net on 2003/09/16 13:17:37 UTC

Saxon and SQLTransformer

Hi,

I can get the "SQLTransformer" sample as supplied in Cocoon 2.1 (eg cocoon/samples/databases/transform/sql-page) to run and return results from the database when using xalan.

However if I use saxon (version 6.5.3 or 7.6.5), the "SQLTransformer" sample throws the following error "org.apache.cocoon.ProcessingException: Failed to execute pipeline.: java.lang.UnsuportedOperationException: The Saxon DOM cannot be updated"

A part of the stack trace was:
Original Exception: java.lang.UnsupportedOperationException: The Saxon DOM cannot be updated
at com.icl.saxon.om.AbstractNode.disallowUpdate(AbstractNode.java:609)
at com.icl.saxon.om.AbstractNode.removeChild(AbstractNode.java:496)
at org.apache.cocoon.transformation.AbstractSAXTransformer.endRecording(AbstractSAXTransformer.java:486)


I then modified AbstractSAXTransformer.endRecording() so that no attempt was made to update the DOM (code changes listed at bottom of this note). 

The modified code was then tested with the "SQLTransformer" sample and xalan, and found to return valid results.

The modified code was then test with the "SQLTransformer" sample and saxon ,and NO results from the database were displayed.

Further investigation revealed that the line

 final DocumentFragment recordedDocFrag = doc.createDocumentFragment();

was the problem, as doc.createDocumentFragment() is returning a null when saxon is used.


Any advise/suggestions/help on how to get a DocumentFragment Object to be returned from doc.createDocumentFragment() when using saxon would be greatly appreciated.


Software levels:
cocoon 2.1
jsdk1.4.2_01
jakarta-tomcat-4.1.27
saxon 6.5.3, saxon 7.6.5

Code changes to AbstractSAXTransformer:
add import org.w3c.dom.NodeList;

In method endRecording() replace the following:
//        Node child;
//        boolean appendedNode = false;
//        while (root.hasChildNodes() == true) {
//            child = root.getFirstChild();
//            root.removeChild(child);
//            // Leave out empty text nodes before any other node
//            if (appendedNode == true
//                || child.getNodeType() != Node.TEXT_NODE
//                || child.getNodeValue().trim().length() > 0) {
//                recordedDocFrag.appendChild(child);
//                appendedNode = true;
//            }
//        }

with 

        if (recordedDocFrag != null) {
            if (root.hasChildNodes() == true) {
                NodeList children = root.getChildNodes();
                Node child;
                boolean appendedNode = false;
                for (int index=0; index<children.getLength(); index++) {
                    child = children.item(index);
                    if (child != null) {
                        // Leave out empty text nodes before any other node
                        if (appendedNode == true
                            || child.getNodeType() != Node.TEXT_NODE
                            || child.getNodeValue().trim().length() > 0) {
                            recordedDocFrag.appendChild(child);
                            appendedNode = true;
                        }
                    }
                }
            }
        }

Regards,
Mark.

__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455

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


Re: Saxon and SQLTransformer

Posted by "J.Pietschmann" <j3...@yahoo.de>.
markwalshaus@netscape.net wrote:
> However if I use saxon (version 6.5.3 or 7.6.5), the "SQLTransformer" sample
> throws the following error "org.apache.cocoon.ProcessingException: Failed to
> execute pipeline.: java.lang.UnsuportedOperationException: The Saxon DOM
> cannot be updated"

Well, the DOM implementation included in the Saxon jar is
read-only.

> Further investigation revealed that the line
> 
>  final DocumentFragment recordedDocFrag = doc.createDocumentFragment();
> 
> was the problem, as doc.createDocumentFragment() is returning a null when
 > saxon is used.

This is part of the read-onlyness of Saxon's DOM implementation.

The solution is to use another DOM impelmentation, possibly the
one delivered with Xerces or included in the 1.4 JDK. Perhaps the
most simple way to achieve this is to remove the DOM classes from
the Saxon jar, as well as the service entries.
Other ideas include putting the Xerces jars into a directory where
they cen be used by Cocoon but are loaded before the Saxon jar
(perhaps the JDK's the servlet engine's lib/endorsed), or somehow
setting the service entries so that they point to a R/W DOM
implementation.

J.Pietschmann


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