You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Krzysztof Witukiewicz <kw...@poczta.onet.pl> on 2003/04/04 22:49:17 UTC

using cocoon with xindice1.1

Hi, I succeed in connecting cocoon with xindice 1.1 But there is some strange thing, namely when I send XUpdate statement from xslt stylesheet, there is everything ok. When I send the same statement from xsp page, XMLDBTransformer cut xmlns:xu=http://www.xmldb.org/xupdate namespace definition from xu:modifications tag, so the update fails. I can hardcode this in XMLDBTransformer, but I just wonder, why this happens (I have no experience with TrAX). If anybody have some clue, please let me know. If anybody have some problems in connecting to Xindice 1.1 at all, I know the solution :)

Re: using cocoon with xindice1.1

Posted by Krzysztof Witukiewicz <kw...@poczta.onet.pl>.
My solution is only for xindice 1.1. Assuming that you have working xindice
on tomcat (and configured cocoon to work with xindice as in article on
cocooncenter.de), the steps are:

1)  copy xmlrpc.jar along with xindice.jar from xindice to cocoon

2) you have to copy the following xindice context declaration

<Context path="/Xindice" docBase="xindice-1.1b" debug="0" reloadable="true">

  <Logger className="org.apache.catalina.logger.FileLogger" debug="0"
verbosity="1" prefix="xindice_log." directory="logs"  timestamp="true"
suffix=".txt"/>

</Context>

to your_tomcat\conf\server.xml, so to connect to xindice you write
"your_host:port/Xindice" (the same effect probably has changing your xindice
directory name, anyway)

3) if you cannot connect to xindice from cocoon at all, there is a problem
with database name, so if you declared XMLDBTransformer in your sitemap.xmap
with <driver>org.apache.xindice.client.xmldb.DatabaseImpl</driver>, change
it to <driver>org.apache.xindice.client.xmldb.xmlrpc.DatabaseImpl</driver>.
It should work, if not you can recompile org.xmldb.api.DatabaseManager to
explicity register "xindice" as database name (not very beautiful, anyway)

4) from this moment you should be able to make XUpdate queries from anywhere
but xsp. The problem with xsp is that it does not output namespace
declaration along with 'prefix:modifications' element. So you can change
XMLDBTransformer code, so in endElement(...) you add code:

} else if("update".equals(operation)) {

      try {

      // *** YOUR CODE ***

            if (document.indexOf(XUPDATE_URI) < 0) {

                  int idx = document.indexOf("<xu:modifications");

                  document = document.substring(idx);

                  idx = document.indexOf(">");

                  String first = document.substring(0, idx);

                  first = first + " xmlns:" + xupdatePrefix + "=\"" +
XUPDATE_URI +"\"";

                  String second = document.substring(idx);

                  document = first.concat(second);

            };

      // *** END OF YOUR CODE ***

            XUpdateQueryService service = (XUpdateQueryService)
collection.getService("XUpdateQueryService", "1.0");



, where XUPDATE_URI = "http://www.xmldb.org/xupdate" and xupdatePrefix you
can retrieve from the method:

public void startPrefixMapping(String prefix, String uri) throws
SAXException {

      if (!processing) {

            super.startPrefixMapping(prefix,uri);

            prefixMap.put(prefix,uri);

      } else if (this.queryHandler != null){

            if (uri.equals(XUPDATE_URI)) xupdatePrefix = prefix;

            this.queryHandler.startPrefixMapping(prefix, uri);

     }

}

where of course String xupdatePrefix is declared global.

I know this is neither nice or elegant solution, but actually i am newbie to
cocoon and sax and don't know yet what to change in xsp classes to work with
XUpdate as they should.

If anybody have better solution, wash off the shame of above code! (probably
it works with Cocoon 2.1dev, but i couldn't manage to get it working - some
pipeline errors).

My system:

tomcat-4.1.24

cocoon 2.04 release

java 1.4.1-b21

xindice-1.1b

There is some useful example on the net (requires points 1-3) on
http://www.candlelightsoftware.com/oetrends/CocoonMadeEasy.htm, but it
requires changes (in sitemap bugs with view declarations and it is supposed
to work under Orion, but you can plug it uder Tomcat easily).

Hope it helps!

----- Original Message -----
From: "Stavros Kounis" <go...@osmosis.gr>
To: <co...@xml.apache.org>
Sent: Saturday, April 05, 2003 3:03 PM
Subject: Re: using cocoon with xindice1.1


>
> how do u send XUpdate statemendt using xsl?
> is there any online example?
>
> i try to send XUPDATE from GUI interfaces but without error msg and
> without any update to occur
> On Fri, 4 Apr 2003, Krzysztof Witukiewicz wrote:
>
> > Hi, I succeed in connecting cocoon with xindice 1.1 But there is some
strange thing, namely when I send XUpdate statement from xslt stylesheet,
there is everything ok. When I send the same statement from xsp page,
XMLDBTransformer cut xmlns:xu=http://www.xmldb.org/xupdate namespace
definition from xu:modifications tag, so the update fails. I can hardcode
this in XMLDBTransformer, but I just wonder, why this happens (I have no
experience with TrAX). If anybody have some clue, please let me know. If
anybody have some problems in connecting to Xindice 1.1 at all, I know the
solution :)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>


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


Re: using cocoon with xindice1.1

Posted by Stavros Kounis <go...@osmosis.gr>.
how do u send XUpdate statemendt using xsl?
is there any online example?

i try to send XUPDATE from GUI interfaces but without error msg and
without any update to occur
On Fri, 4 Apr 2003, Krzysztof Witukiewicz wrote:

> Hi, I succeed in connecting cocoon with xindice 1.1 But there is some strange thing, namely when I send XUpdate statement from xslt stylesheet, there is everything ok. When I send the same statement from xsp page, XMLDBTransformer cut xmlns:xu=http://www.xmldb.org/xupdate namespace definition from xu:modifications tag, so the update fails. I can hardcode this in XMLDBTransformer, but I just wonder, why this happens (I have no experience with TrAX). If anybody have some clue, please let me know. If anybody have some problems in connecting to Xindice 1.1 at all, I know the solution :)



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