cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Perry Molendijk" <pe...@inflexions.com>
Subject Xindice and Cocoon How To
Date Fri, 22 Feb 2002 07:42:10 GMT
Infexions (WA) Pty LtdHope this is useful to anyone

Finally got around to attempt to make xindice / dbxml work with C2.
Checked the FAQ's and archive and ended up very confused.
Anyway I kind of summarised all the advice / postings I found and got it to
work [in the end].

Here is a rundown on what I did / modified to cocoon to get it to work.

The environment Win2K, Cocoon 2.0.1, Tomcat 4.0.1 and xindice-1.0rc1

Assumption: xindice is running on localhost:4080 and the addressbook example
db has been created.

There are apparently two ways of doing this:
1. using a generator
2. using a source-handler

In a recent posting it was noted however that the generator will be
deprecated shortly, so first I got rid of the bits in sitemap.xmap that deal
with the generator:

First comment out this section (it's near the top of sitemap.xmap)

<map:generator name="xmldb"
src="org.apache.cocoon.generation.XMLDBGenerator"
logger="sitemap.generator.xmldb">
    <driver>org.dbxml.client.xmldb.DatabaseImpl</driver>
    <base>xmldb:dbxml:///db/</base>
   </map:generator>
   <map:generator name="xmldbcollection"
src="org.apache.cocoon.generation.XMLDBCollectionGenerator"
logger="sitemap.generator.xmldbcollection">
    <driver>org.dbxml.client.xmldb.DatabaseImpl</driver>
    <base>xmldb:dbxml:///db/</base>
   </map:generator>

Next comment out these lines (near the end of sitemap.xmap):

   <map:match pattern="xmldb-generator/db/**/">
    <map:generate type="xmldbcollection" src="/{1}"/>
    <map:serialize type="xml"/>
   </map:match>
   <map:match pattern="xmldb-generator/db/**">
    <map:generate type="xmldb" src="/{1}"/>
    <map:serialize type="xml"/>
   </map:match>

Now modify the remaining map:match entry:

   <map:match pattern="xmldb/**">
    <map:match type="request-parameter" pattern="xpath">
     <map:generate src="xmldb:dbxml://localhost:4080/{../1}#{1}"/>
     <map:serialize type="xml"/>
    </map:match>
    <map:generate src="xmldb:dbxml://localhost:4080/{1}"/>
    <map:serialize type="xml"/>
   </map:match>

so it looks like this:

   <map:match pattern="xmldb/**">
    <map:match type="request-parameter" pattern="xpath">
     <map:generate src="xmldb:xindice://localhost:4080/db/{../1}#{1}"/>
     <map:serialize type="xml"/>
    </map:match>
    <map:generate src="xmldb:xindice://localhost:4080/db/{1}"/>
    <map:serialize type="xml"/>
   </map:match>

Replace:
xmldb:dbxml://localhost:4080/
With:
xmldb:xindice://localhost:4080/db/

Untill I added the "db/" at the end I was getting an error saying a file
named:
XXXX_bootstrap.ior not found. Where XXXX is the collection name used in the
request. In fact if you look in %XINDICE_HOME%/docs there is only one .ior
file and it's called db_bootstrap.ior.

Next to cocoon.xconf. Modify the following lines:

 <source-handler logger="core.source-handler">
  <!-- xmldb pseudo protocol -->
  <protocol name="xmldb"
class="org.apache.cocoon.components.source.XMLDBSourceFactory">
   <!-- dbXML driver -->
   <driver type="dbxml" class="org.dbxml.client.xmldb.DatabaseImpl"/>
   <!-- Add here other XML:DB compliant databases drivers -->
  </protocol>
 </source-handler>

so they look like this:

 <source-handler logger="core.source-handler">
  <!-- xmldb pseudo protocol -->
  <protocol name="xmldb"
class="org.apache.cocoon.components.source.XMLDBSourceFactory">
   <!-- xindice driver -->
   <driver type="xindice"
class="org.apache.xindice.client.xmldb.DatabaseImpl"/>
   <!-- Add here other XML:DB compliant databases drivers -->
  </protocol>
 </source-handler>

Copy xindice.jar into the cocoon\WEB-INF\lib directory.

Start xindice, if it isn't running yet.

Start Tomcat.

And try: http://localhost:8080/cocoon/xmldb/addressbook/

The result looks something like this [I have three entries in the
addressbook db]:

<?xml version="1.0" encoding="UTF-8"?>
<collection:collections resources="3" collections="0"
xmlns:collection="http://apache.org/cocoon/xmldb/1.0">
 <collection:resource name="0100007f1f9fdabb000000ec2b2a4110"/>
 <collection:resource name="0100007f1f9fdabb000000ec2b30c130"/>
 <collection:resource name="0100007f1f9fdabb000000ec2b8cabd3"/>
</collection:collections>

To see all the entries in you addressbook db try:
http://localhost:8080/cocoon/xmldb/addressbook/?xpath=//person

Although all this is working sweet, I do get this error in error.log:

ERROR   (2002-02-22) 13:51.08:468   [sitemap.generator.velocity]
(/cocoon/xmldb/addressbook/) HttpProcessor[82][4]/VelocityGenerator:
ResourceManager : unable to find resource 'VM_global_library.vm' in any
resource loader.
ERROR   (2002-02-22) 13:51.08:578   [sitemap.generator.velocity]
(/cocoon/xmldb/addressbook/) HttpProcessor[82][4]/VelocityGenerator:
ResourceManager : unable to find resource 'VM_global_library.vm' in any
resource loader.

Always 2 entries like this but all seems to running fine.

I have written this in StyleBook format. You can download it from:
http://members.iinet.net.au/~xions/dev/xindice.zip
Unzip it to %PATH_TO_SERVLET_ENGINE%\webapps\cocoon\documentation\xdocs
Access it via:
http://localhost:8080/cocoon/documents/xindice/index.html


Inflexions (WA) Pty Ltd
to....
body
Perry Molendijk

Inflexions (WA) Pty Ltd
PO Box 57
Inglewood
WA 6052
Australia
Tel: (+61) 0401 677 453

IMPORTANT INFORMATION: This message and any files transmitted with it are
confidential and should be read only by those persons to whom it is
addressed. If you have received this message in error, please notify us
immediately by way of reply. Please also destroy and delete the message from
your computer. Any unauthorised form of reproduction of this message is
strictly prohibited. It is the duty of the recipient to virus scan and
otherwise test the information provided before loading onto any computer
system. Inflexions (WA) Pty Ltd does not warrant that the information is
free of a virus or any other defect or error. Inflexions (WA) Pty Ltd is not
liable for the proper and complete transmission of the information contained
in this communication, nor for any delay in its receipt. Any views expressed
in this message are those of the individual sender, except where the sender
specifically states them to be the views of Inflexions (WA) Pty Ltd.


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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


Mime
View raw message