You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Johnson <jo...@erp.tw> on 2006/02/01 07:21:46 UTC

Re: Updating Xindice with Request Data

You're welcome, additional info, if you want delete or do something more than load and save document from Xindice, you must write some java  class like this to achive it.

package org.apache.xindice.examples;

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;

import java.io.*;

public class ShpkXIN {
public static void deleteDocument(String args) throws Exception {
 Collection col = null;
 try {
  String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
  Class c = Class.forName(driver);

  Database database = (Database) c.newInstance();
  DatabaseManager.registerDatabase(database);
  col = DatabaseManager.getCollection("xmldb:xindice://localhost:8080/db/shpk");

  Resource document = col.getResource(args);
  col.removeResource(document);
 }
 catch (XMLDBException e) {
  System.err.println("XML:DB Exception occured " + e.errorCode);
 }
 finally {
  if (col != null) {
   col.close();
  }
 }
}

public static void retrieveDocument(String args) throws Exception {
 Collection col = null;
 try {
  String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
  Class c = Class.forName(driver);

  Database database = (Database) c.newInstance();
  DatabaseManager.registerDatabase(database);
  col = DatabaseManager.getCollection("xmldb:xindice://localhost:8080/db/shpk");

  XMLResource document = (XMLResource) col.getResource(args);
  if (document != null) {
   System.out.println("Document " + args);
   System.out.println(document.getContent());
  }
  else {
   System.out.println("Document not found");
  }
 }
 catch (XMLDBException e) {
  System.err.println("XML:DB Exception occured " + e.errorCode);
 }
 finally {
  if (col != null) {
   col.close();
  }
 }
}

}

and in flowscript

 var dao_xindice = new Packages.org.apache.xindice.examples.ShpkXIN();

 var button4 = form.lookupWidget("delete");
 button4.onClick = function() {
  var document = wid.shpk_cpdh.value + wid.rev.value + ".xml";
  dao_xindice.deleteDocument(document);
  form.load(blank); 
  wid.shpk_jdrq.value = new java.util.Date();
  wid.shpk_xgrq.value = new java.util.Date();
  ls_rev = null;
  ls_tlc = null;
 }

even with OJB, you must write something linke this, not only sitemap.
with this method, you can easily treat XML DB like RDB.

best regards

johnson

  ----- Original Message ----- 
  From: Mike Casey 
  To: users@cocoon.apache.org 
  Sent: Wednesday, February 01, 2006 5:58 AM
  Subject: Re: Updating Xindice with Request Data


  Brilliant, that is exactly what I need... its not quite just a sitemap thing like I was hoping for, but it is good enough to get it all working. Thankyou to all!

  Mike


  On 2/1/06, Johnson <jo...@erp.tw> wrote:
    Hi!

    We use this method

    var wid = form.lookupWidget();
    form.createBinding("forms/shpk_bind.xml");
    var documentURI = cocoon.parameters["documentURI"];
    if (documentURI == "xmldb:xindice://localhost:8080/db/shpk/") {documentURI 
    = cocoon.parameters["documentURI2"];}
    var document = loadDocument(documentURI);

      form.load(document);

    ....
    saveDocument(document, "xmldb:xindice://localhost:8080/db/shpk/" +
    wid.shpk_cpdh.value + wid.rev.value + ".xml");

    Best Regards

    johnson


    ----- Original Message -----
    From: "Jonas Lundberg" <my.name.is.hans@gmail.com >
    To: <us...@cocoon.apache.org>; <An...@oulu.fi>
    Sent: Tuesday, January 31, 2006 4:59 PM
    Subject: Re: Updating Xindice with Request Data 


    >I see. I was looking at the downloads page...
    >
    > Regards
    > Hans
    >
    > On 1/31/06, Andre Juffer <aj...@sun3.oulu.fi> wrote:
    >> Jonas Lundberg wrote:
    >> > It seems that no one works on Xindice anymore. At least, I have found
    >> > no new versions since 2004.
    >>
    >> The last version is 1.1b5-dev (May 25 2005) 
    >>
    >> See http://xml.apache.org/xindice/changes.html
    >>
    >> You can download the source code with svn.
    >>
    >> > I would recommend that you use eXist instead of Xindice, if you want 
    >> > an XML database.
    >> > http://exist.sourceforge.net/
    >>
    >> >
    >> > Regards
    >> > Hans
    >> >
    >> > On 1/31/06, Mike Casey <we...@gmail.com> wrote:
    >> >
    >> >>Hi All,
    >> >>
    >> >> I am currently working on an implementation of a wiki type site that 
    >> >> uses
    >> >>XML for Wiki syntax, partly to help learn NXBs/Cocoon and partly
    >> >>because I
    >> >>could not find a suitable product out there to meet my needs. 
    >> >>
    >> >> The XMLDB block samples has some good examples on how to update
    >> >> Xindice
    >> >>using XML files which is all very well in good however I need to figure 
    >> >>out
    >> >>how to pull xml data out of a CForm and then push it into Xindice. The
    >> >>sample has the pipeline
    >> >>
    >> >> <map:match pattern="populate"> 
    >> >>         <map:generate src="populate.xml"/>
    >> >>         <map:transform type="cinclude"/>
    >> >>         <map:transform type="xmldb"/> 
    >> >>         <map:serialize/>
    >> >>  </map:match>
    >> >>
    >> >> Where ofcourse the generator looks for a physical xml file. Does
    >> >> anyone 
    >> >>have any hints on how I might acheive this? I am reasonably new to
    >> >>Cocoon so
    >> >>forgive me if the answer you return is blatantly obvious!
    >> >>
    >> >> Cheers, 
    >> >>
    >> >> Mike Casey
    >> >> Wellington
    >> >> New Zealand
    >> >>
    >> >
    >> >
    >> > --------------------------------------------------------------------- 
    >> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
    >> > For additional commands, e-mail: users-help@cocoon.apache.org
    >> >
    >> >
    >>
    >>
    >> --
    >> Andre H. Juffer              | Phone: +358-8-553 1161
    >> The Biocenter and            | Fax: +358-8-553-1141
    >>      the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
    >> University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
    >>
    >> ---------------------------------------------------------------------
    >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
    >> For additional commands, e-mail: users-help@cocoon.apache.org
    >>
    >>
    >
    > --------------------------------------------------------------------- 
    > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
    > For additional commands, e-mail: users-help@cocoon.apache.org 
    >


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




Re: Updating Xindice with Request Data

Posted by Johnson <jo...@erp.tw>.
Hi Mike!

We don't had a function call createDocument.

All we use is the default function of Javascript, Like loadDocument, we had a blank doc to be a template, load it than save it.

Yes we use binding, It's almost the same to load and save a XML file in filesystem or Xindice.

If you want to do more like deleteDocument I said before, you must define it yourself, like the sample of java below, put the java class to cocoon/WEB-INF/classes...than you can use it in flowscript.  

  ----- Original Message ----- 
  From: Mike Casey 
  To: users@cocoon.apache.org 
  Sent: Friday, February 03, 2006 4:58 AM
  Subject: Re: Updating Xindice with Request Data


  Thanks Johnson,

  In closing, would you tell me where the createDocument, loadDocument and saveDocument flowscript methods are locates/how do we use them? Or alternatively if we have to, how do you create them? On the cocoon Wiki some of the examples show code for these methods but before I attempt to implement them, is there an easier way to get them? 

  At present the cocoon stack trace returns

ReferenceError: "createDocument" is not defined. (file:/home/msc/dev/server/apache-tomcat-5.5.12/webapps/xwiki/forms/flow.js; line 14)
I notice that you also use binding. It this a requirement or can you do this operation using just the Forms block.

  Cheers,

  MIke



  On 2/1/06, Johnson <jo...@erp.tw> wrote:
    You're welcome, additional info, if you want delete or do something more than load and save document from Xindice, you must write some java  class like this to achive it.

    package org.apache.xindice.examples;

    import org.xmldb.api.base.*;
    import org.xmldb.api.modules.*;
    import org.xmldb.api.*;

    import java.io.*;

    public class ShpkXIN {
    public static void deleteDocument(String args) throws Exception {
     Collection col = null;
     try {
      String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
      Class c = Class.forName(driver);

      Database database = (Database) c.newInstance();
      DatabaseManager.registerDatabase(database);
      col = DatabaseManager.getCollection("xmldb:xindice://localhost:8080/db/shpk");

      Resource document = col.getResource(args);
      col.removeResource(document);
     }
     catch (XMLDBException e) {
      System.err.println("XML:DB Exception occured " + e.errorCode);
     }
     finally {
      if (col != null) {
       col.close();
      }
     }
    }

    public static void retrieveDocument(String args) throws Exception {
     Collection col = null;
     try {
      String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
      Class c = Class.forName(driver);

      Database database = (Database) c.newInstance();
      DatabaseManager.registerDatabase(database);
      col = DatabaseManager.getCollection("xmldb:xindice://localhost:8080/db/shpk");

      XMLResource document = (XMLResource) col.getResource(args);
      if (document != null) {
       System.out.println("Document " + args);
       System.out.println(document.getContent());
      }
      else {
       System.out.println("Document not found");
      }
     }
     catch (XMLDBException e) {
      System.err.println("XML:DB Exception occured " + e.errorCode);
     }
     finally {
      if (col != null) {
       col.close();
      }
     }
    }

    }

    and in flowscript

     var dao_xindice = new Packages.org.apache.xindice.examples.ShpkXIN();

     var button4 = form.lookupWidget("delete");
     button4.onClick = function() {
      var document = wid.shpk_cpdh.value + wid.rev.value + ".xml";
      dao_xindice.deleteDocument(document);
      form.load(blank); 
      wid.shpk_jdrq.value = new java.util.Date();
      wid.shpk_xgrq.value = new java.util.Date();
      ls_rev = null;
      ls_tlc = null;
     }

    even with OJB, you must write something linke this, not only sitemap.
    with this method, you can easily treat XML DB like RDB.

    best regards

    johnson

      ----- Original Message ----- 
      From: Mike Casey 
      To: users@cocoon.apache.org 
      Sent: Wednesday, February 01, 2006 5:58 AM
      Subject: Re: Updating Xindice with Request Data


      Brilliant, that is exactly what I need... its not quite just a sitemap thing like I was hoping for, but it is good enough to get it all working. Thankyou to all!

      Mike


      On 2/1/06, Johnson <jo...@erp.tw> wrote: 
        Hi!

        We use this method

        var wid = form.lookupWidget();
        form.createBinding("forms/shpk_bind.xml");
        var documentURI = cocoon.parameters["documentURI"];
        if (documentURI == "xmldb:xindice://localhost:8080/db/shpk/") {documentURI 
        = cocoon.parameters["documentURI2"];}
        var document = loadDocument(documentURI);

          form.load(document);

        ....
        saveDocument(document, "xmldb:xindice://localhost:8080/db/shpk/" +
        wid.shpk_cpdh.value + wid.rev.value + ".xml");

        Best Regards

        johnson


        ----- Original Message -----
        From: "Jonas Lundberg" <my.name.is.hans@gmail.com >
        To: <us...@cocoon.apache.org>; <An...@oulu.fi>
        Sent: Tuesday, January 31, 2006 4:59 PM
        Subject: Re: Updating Xindice with Request Data 


        >I see. I was looking at the downloads page...
        >
        > Regards
        > Hans
        >
        > On 1/31/06, Andre Juffer <aj...@sun3.oulu.fi> wrote:
        >> Jonas Lundberg wrote:
        >> > It seems that no one works on Xindice anymore. At least, I have found
        >> > no new versions since 2004.
        >>
        >> The last version is 1.1b5-dev (May 25 2005) 
        >>
        >> See http://xml.apache.org/xindice/changes.html
        >>
        >> You can download the source code with svn.
        >>
        >> > I would recommend that you use eXist instead of Xindice, if you want 
        >> > an XML database.
        >> > http://exist.sourceforge.net/
        >>
        >> >
        >> > Regards
        >> > Hans
        >> >
        >> > On 1/31/06, Mike Casey <we...@gmail.com> wrote:
        >> >
        >> >>Hi All,
        >> >>
        >> >> I am currently working on an implementation of a wiki type site that 
        >> >> uses
        >> >>XML for Wiki syntax, partly to help learn NXBs/Cocoon and partly
        >> >>because I
        >> >>could not find a suitable product out there to meet my needs. 
        >> >>
        >> >> The XMLDB block samples has some good examples on how to update
        >> >> Xindice
        >> >>using XML files which is all very well in good however I need to figure 
        >> >>out
        >> >>how to pull xml data out of a CForm and then push it into Xindice. The
        >> >>sample has the pipeline
        >> >>
        >> >> <map:match pattern="populate"> 
        >> >>         <map:generate src="populate.xml"/>
        >> >>         <map:transform type="cinclude"/>
        >> >>         <map:transform type="xmldb"/> 
        >> >>         <map:serialize/>
        >> >>  </map:match>
        >> >>
        >> >> Where ofcourse the generator looks for a physical xml file. Does
        >> >> anyone 
        >> >>have any hints on how I might acheive this? I am reasonably new to
        >> >>Cocoon so
        >> >>forgive me if the answer you return is blatantly obvious!
        >> >>
        >> >> Cheers, 
        >> >>
        >> >> Mike Casey
        >> >> Wellington
        >> >> New Zealand
        >> >>
        >> >
        >> >
        >> > --------------------------------------------------------------------- 
        >> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
        >> > For additional commands, e-mail: users-help@cocoon.apache.org
        >> >
        >> >
        >>
        >>
        >> --
        >> Andre H. Juffer              | Phone: +358-8-553 1161
        >> The Biocenter and            | Fax: +358-8-553-1141
        >>      the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
        >> University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
        >>
        >> ---------------------------------------------------------------------
        >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
        >> For additional commands, e-mail: users-help@cocoon.apache.org
        >>
        >>
        >
        > --------------------------------------------------------------------- 
        > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
        > For additional commands, e-mail: users-help@cocoon.apache.org 
        >


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






Re: Updating Xindice with Request Data

Posted by Mike Casey <we...@gmail.com>.
Thanks Johnson,

In closing, would you tell me where the createDocument, loadDocument and
saveDocument flowscript methods are locates/how do we use them? Or
alternatively if we have to, how do you create them? On the cocoon Wiki some
of the examples show code for these methods but before I attempt to
implement them, is there an easier way to get them?

At present the cocoon stack trace returns

ReferenceError: "createDocument" is not defined.
(file:/home/msc/dev/server/apache-tomcat-5.5.12/webapps/xwiki/forms/flow.js;
line 14)


I notice that you also use binding. It this a requirement or can you do this
operation using just the Forms block.

Cheers,

MIke


On 2/1/06, Johnson <jo...@erp.tw> wrote:
>
> You're welcome, additional info, if you want delete or do something more
> than load and save document from Xindice, you must write some java  class
> like this to achive it.
>
> package org.apache.xindice.examples;
>
> import org.xmldb.api.base.*;
> import org.xmldb.api.modules.*;
> import org.xmldb.api.*;
>
> import java.io.*;
>
> public class ShpkXIN {
> public static void deleteDocument(String args) throws Exception {
>  Collection col = null;
>  try {
>   String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
>   Class c = Class.forName(driver);
>
>   Database database = (Database) c.newInstance();
>   DatabaseManager.registerDatabase(database);
>   col = DatabaseManager.getCollection
> ("xmldb:xindice://localhost:8080/db/shpk");
>
>   Resource document = col.getResource(args);
>   col.removeResource(document);
>  }
>  catch (XMLDBException e) {
>   System.err.println("XML:DB Exception occured " + e.errorCode);
>  }
>  finally {
>   if (col != null) {
>    col.close();
>   }
>  }
> }
>
> public static void retrieveDocument(String args) throws Exception {
>  Collection col = null;
>  try {
>   String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
>   Class c = Class.forName(driver);
>
>   Database database = (Database) c.newInstance();
>   DatabaseManager.registerDatabase(database);
>   col = DatabaseManager.getCollection
> ("xmldb:xindice://localhost:8080/db/shpk");
>
>   XMLResource document = (XMLResource) col.getResource(args);
>   if (document != null) {
>    System.out.println("Document " + args);
>    System.out.println(document.getContent());
>   }
>   else {
>    System.out.println("Document not found");
>   }
>  }
>  catch (XMLDBException e) {
>   System.err.println("XML:DB Exception occured " + e.errorCode);
>  }
>  finally {
>   if (col != null) {
>    col.close();
>   }
>  }
> }
>
> }
> and in flowscript
>
>  var dao_xindice = new Packages.org.apache.xindice.examples.ShpkXIN();
>
>  var button4 = form.lookupWidget("delete");
>  button4.onClick = function() {
>   var document = wid.shpk_cpdh.value + wid.rev.value + ".xml";
>   dao_xindice.deleteDocument(document);
>   form.load(blank);
>   wid.shpk_jdrq.value = new java.util.Date();
>   wid.shpk_xgrq.value = new java.util.Date();
>   ls_rev = null;
>   ls_tlc = null;
>  }
> even with OJB, you must write something linke this, not only sitemap.
> with this method, you can easily treat XML DB like RDB.
>
> best regards
>
> johnson
>
>
> ----- Original Message -----
> *From:* Mike Casey <we...@gmail.com>
> *To:* users@cocoon.apache.org
> *Sent:* Wednesday, February 01, 2006 5:58 AM
> *Subject:* Re: Updating Xindice with Request Data
>
> Brilliant, that is exactly what I need... its not quite just a sitemap
> thing like I was hoping for, but it is good enough to get it all working.
> Thankyou to all!
>
> Mike
>
> On 2/1/06, Johnson <jo...@erp.tw> wrote:
> >
> > Hi!
> >
> > We use this method
> >
> > var wid = form.lookupWidget();
> > form.createBinding("forms/shpk_bind.xml");
> > var documentURI = cocoon.parameters["documentURI"];
> > if (documentURI == "xmldb:xindice://localhost:8080/db/shpk/")
> > {documentURI
> > = cocoon.parameters["documentURI2"];}
> > var document = loadDocument(documentURI);
> >
> >   form.load(document);
> >
> > ....
> > saveDocument(document, "xmldb:xindice://localhost:8080/db/shpk/" +
> > wid.shpk_cpdh.value + wid.rev.value + ".xml");
> >
> > Best Regards
> >
> > johnson
> >
> >
> > ----- Original Message -----
> > From: "Jonas Lundberg" <my.name.is.hans@gmail.com >
> > To: <us...@cocoon.apache.org>; <An...@oulu.fi>
> > Sent: Tuesday, January 31, 2006 4:59 PM
> > Subject: Re: Updating Xindice with Request Data
> >
> >
> > >I see. I was looking at the downloads page...
> > >
> > > Regards
> > > Hans
> > >
> > > On 1/31/06, Andre Juffer <aj...@sun3.oulu.fi> wrote:
> > >> Jonas Lundberg wrote:
> > >> > It seems that no one works on Xindice anymore. At least, I have
> > found
> > >> > no new versions since 2004.
> > >>
> > >> The last version is 1.1b5-dev (May 25 2005)
> > >>
> > >> See http://xml.apache.org/xindice/changes.html
> > >>
> > >> You can download the source code with svn.
> > >>
> > >> > I would recommend that you use eXist instead of Xindice, if you
> > want
> > >> > an XML database.
> > >> > http://exist.sourceforge.net/
> > >>
> > >> >
> > >> > Regards
> > >> > Hans
> > >> >
> > >> > On 1/31/06, Mike Casey <we...@gmail.com> wrote:
> > >> >
> > >> >>Hi All,
> > >> >>
> > >> >> I am currently working on an implementation of a wiki type site
> > that
> > >> >> uses
> > >> >>XML for Wiki syntax, partly to help learn NXBs/Cocoon and partly
> > >> >>because I
> > >> >>could not find a suitable product out there to meet my needs.
> > >> >>
> > >> >> The XMLDB block samples has some good examples on how to update
> > >> >> Xindice
> > >> >>using XML files which is all very well in good however I need to
> > figure
> > >> >>out
> > >> >>how to pull xml data out of a CForm and then push it into Xindice.
> > The
> > >> >>sample has the pipeline
> > >> >>
> > >> >> <map:match pattern="populate">
> > >> >>         <map:generate src="populate.xml"/>
> > >> >>         <map:transform type="cinclude"/>
> > >> >>         <map:transform type="xmldb"/>
> > >> >>         <map:serialize/>
> > >> >>  </map:match>
> > >> >>
> > >> >> Where ofcourse the generator looks for a physical xml file. Does
> > >> >> anyone
> > >> >>have any hints on how I might acheive this? I am reasonably new to
> > >> >>Cocoon so
> > >> >>forgive me if the answer you return is blatantly obvious!
> > >> >>
> > >> >> Cheers,
> > >> >>
> > >> >> Mike Casey
> > >> >> Wellington
> > >> >> New Zealand
> > >> >>
> > >> >
> > >> >
> > >> >
> > ---------------------------------------------------------------------
> > >> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > >> > For additional commands, e-mail: users-help@cocoon.apache.org
> > >> >
> > >> >
> > >>
> > >>
> > >> --
> > >> Andre H. Juffer              | Phone: +358-8-553 1161
> > >> The Biocenter and            | Fax: +358-8-553-1141
> > >>      the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
> > >> University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > >> For additional commands, e-mail: users-help@cocoon.apache.org
> > >>
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > > For additional commands, e-mail: users-help@cocoon.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
>