cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wicksteed, Charles" <charles.wickst...@logicacmg.com>
Subject New toSAX method in SourceUtil should have different name
Date Tue, 13 Sep 2005 09:05:21 GMT
Hi,

A new toSAX() method was introduced in
org/apache/cocoon/components/source/SourceUtil.java in version 165317,
when some refactoring was done to clean up the exception handling.  This
causes a problem when you try to call toSAX() from Flowscript with
certain arguments, because the Flowscript interpreter can't work out
which of the toSAX() methods to call.  I think the new method needs to
have a different name and/or be made private.  It is not actually on the
same level as the existing toSAX() methods, but is called from them.

I have not put this in Bugzilla, because it is the first bug I have
reported and I wanted to bounce it off you first.  If Bugzilla is the
way to go, let me know and I will enter it into Bugzilla.

Patch below.  I chose "xmlizableToSAX" as the new name.

I am running the version of Cocoon (some time later than 2.1.7) which
comes with Lenya 1.2.4 for Windows.  This bit of work is independent of
Lenya, but I'm using its Cocoon installation, augmented a bit, to
develop some Forms.

The problem arises when trying to load data into a "Cocoon Forms" Form
using loadXML() where the source is a pipeline.

sitemap.xmap:

<map:match pattern="mg_get_data">
  <map:generate type="file" src="mg_demo_users_getdata.xml"/>
  <map:transform type="sql">
    <map:parameter name="use-connection" value="myguide"/>
  </map:transform>
  <map:transform src="mg-demo_users_formatdata.xsl" />
  <map:serialize type="xml"/>
</map:match>

Flowscript:

    var form = new Form("mg_demo_users_def.xml");

    // This version uses no binding definition file.
    // Instead we use the XMLAdapter as an alternative.
    // We get the data from a Cocoon pipeline which emits the data
    // in elements whose names are the same as the fields in which the
data lives.
    // For the repeater, we use a special "item" element.
    // See the JavaDoc in
cocoon-2.1.7\src\blocks\forms\java\org\apache\cocoon\forms\util\XMLAdapt
er.java
    // mg_get_data in the local sitemap runs a fixed SQL query through
the SQL transformer
    // and formats the results into elements with the same names as the
form fields
    // using mg-demo_users_formatdata.xsl
    form.loadXML("cocoon:/mg_get_data");

Error message:

 org.mozilla.javascript.EvaluatorException:
"resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 226:
The choice of Java method
org.apache.cocoon.components.source.SourceUtil.toSAX matching JavaScript
argument types
(org.apache.cocoon.components.source.impl.SitemapSource,org.apache.cocoo
n.forms.util.XMLAdapter) is ambiguous; candidate methods are: void
toSAX(org.apache.excalibur.xml.sax.XMLizable,org.xml.sax.ContentHandler)
, void
toSAX(org.apache.excalibur.source.Source,org.xml.sax.ContentHandler) 

which enabled me to track it down pretty quickly.
I think line 226 must be:
 
Packages.org.apache.cocoon.components.source.SourceUtil.toSAX(source,
this.getXML());
in the loadXML function (that's line 217 in plain Cocoon version 2.1.7).

Thanks,

Charles Wicksteed
LogicaCMG
London, UK
------------------------------------------------------------------------
-
--- SourceUtil-178777.java	Tue Aug 30 12:47:49 2005
+++ SourceUtil.java	Tue Sep 13 08:54:03 2005
@@ -93,7 +93,7 @@
      *
      * @param  source    the data
      */
-    static public void toSAX(XMLizable source,
+    static public void xmlizableToSAX(XMLizable source,
                              ContentHandler handler)
     throws SAXException, IOException, ProcessingException {
         try {
@@ -177,7 +177,7 @@
                              ContentHandler handler)
     throws SAXException, IOException, ProcessingException {
         if (source instanceof XMLizable) {
-            toSAX((XMLizable) source, handler);
+            xmlizableToSAX((XMLizable) source, handler);
         } else {
             String mimeType = source.getMimeType();
             if (null == mimeType) {
@@ -217,7 +217,7 @@
                              ContentHandler handler)
     throws SAXException, IOException, ProcessingException {
         if (source instanceof XMLizable) {
-            toSAX((XMLizable) source, handler);
+            xmlizableToSAX((XMLizable) source, handler);
         } else {
             String mimeType = source.getMimeType();
             if (null == mimeType) {
@@ -257,7 +257,7 @@
                              ContentHandler handler)
     throws SAXException, IOException, ProcessingException {
         if (source instanceof XMLizable) {
-            toSAX((XMLizable) source, handler);
+            xmlizableToSAX((XMLizable) source, handler);
         } else {
             SAXParser parser = null;
             try {
@@ -317,7 +317,7 @@
                              ContentHandler handler)
     throws SAXException, IOException, ProcessingException {
         if (source instanceof XMLizable) {
-            toSAX((XMLizable) source, handler);
+            xmlizableToSAX((XMLizable) source, handler);
         } else {
             SAXParser parser = null;
             try {
------------------------------------------------------------------------
-
--


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It
may contain proprietary material, confidential information and/or be subject to legal privilege.
It should not be copied, disclosed to, retained or used by, any other party. If you are not
an intended recipient then please promptly delete this e-mail and any attachment and all copies
and inform the sender. Thank you.

Mime
View raw message