You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Richard Hosking <ho...@yahoo.co.uk> on 2002/03/04 11:55:25 UTC

XPath and attributes

(Using dbXML beta 4, Java 1.4 rc, WinXP)

I'm trying to reference the 'src:key' attribute of the following
document using XPath....

<?xml version="1.0" ?> 
<node xmlns:src="http://www.dbxml.org/Query" src:col="/db/root/ocs" 
src:key="37005840459e2954000000ec5d2a0272">
</node>

The XPath query i've been trying is...

/node[@src:key = '37005840459e2954000000ec5d2a0272']

and dbXML generates lots of 'debug' exceptions... not very helpful!

DEBUG> javax.xml.transform.TransformerException: Expected ], 
but found: '37005840459e2954000000ec5d2a0272'
DEBUG> javax.xml.transform.TransformerException: Extra illegal 
tokens: ''37005840459e2954000000ec5d2a0272'', ']'

If I omit the namespace bit 'src:', then no exceptions, but no
documents returned.

Can anyone help?

Regards,
Richard.





Re: XPath and attributes

Posted by Kimbro Staken <ks...@xmldatabases.org>.
You can't, the src:key attribute is added to the result after the query is 
executed. We're looking at extending the ability to query across metadata 
like this. it might be a couple releases before it shows up though.

On Monday, March 4, 2002, at 07:33 AM, Richard Hosking wrote:

> Yes, I know how to do it from code...  I need to use
> XPath though, because the query string is read from a
> script file.
>
> Regards,
> Richard.
>
> ----- Original Message -----
> From: "W. Peschke" <Wo...@gmx.ch>
> To: <xi...@xml.apache.org>; "'Richard Hosking'" <hoskingrichard@y
> ahoo.co.uk>
> Sent: Monday, March 04, 2002 12:58 PM
> Subject: AW: XPath and attributes
>
>
> Why don't you use: Collection.getResource( your_wanted_id );
> Instead?
>
>
> Wolfram
>
> -----Ursprüngliche Nachricht-----
> Von: Richard Hosking [mailto:hoskingrichard@yahoo.co.uk]
> Gesendet: Montag, 4. März 2002 11:55
> An: xindice-users@xml.apache.org
> Betreff: XPath and attributes
>
>
> (Using dbXML beta 4, Java 1.4 rc, WinXP)
>
> I'm trying to reference the 'src:key' attribute of the following
> document using XPath....
>
> <?xml version="1.0" ?>
> <node xmlns:src="http://www.dbxml.org/Query" src:col="/db/root/ocs"
> src:key="37005840459e2954000000ec5d2a0272">
> </node>
>
> The XPath query i've been trying is...
>
> /node[@src:key = '37005840459e2954000000ec5d2a0272']
>
> and dbXML generates lots of 'debug' exceptions... not very helpful!
>
> DEBUG> javax.xml.transform.TransformerException: Expected ],
> but found: '37005840459e2954000000ec5d2a0272'
> DEBUG> javax.xml.transform.TransformerException: Extra illegal
> tokens: ''37005840459e2954000000ec5d2a0272'', ']'
>
> If I omit the namespace bit 'src:', then no exceptions, but no
> documents returned.
>
> Can anyone help?
>
> Regards,
> Richard.
>
>
>
>
>
>
Kimbro Staken - http://www.kstaken.org - http://www.xmldatabases.org
Apache Xindice native XML database http://xml.apache.org/xindice
XML:DB Initiative http://www.xmldb.org
Senior Technologist (Your company name here)


Re: XUpdate

Posted by "Mark J. Stang" <ma...@earthlink.net>.
Matthew,
There is an xmldb-xupdate.jar, maybe you are picking up an old one?
Did you try removing the "<?xml version="1.0">"?

Mark

Matthew Egbert wrote:

> Thanks for the speedy reply Mark,
>
>   Unfortunately, it doesn't seem to be the collection that's causing the
> problem...
>
> xindiceadmin lc -c /db
>
> locates the collection no prob, and I'm capable of performing:
>
> - XPath queries to the collection
> - document submission to the collection
> (both via a java application which closely resembles the example apps,
> and both without a hitch)
>
> As I've worked with Xindice, axis and tomcat, I have had a few problems
> which have been related to the java classpath.  But this doesn't seem to
> be that kind of error...am I wrong?  Which packages are to be included in
> the classpath to use xupdate (aside from the obvious xmldb.jar)?
>
> Thanks again for the help.
>
> Cheers,
>
> Matthew
>
> On Mon, 4 Mar 2002, Mark J. Stang wrote:
>
> > I love responding to my own e-mail ;-).
> >
> > Also, try:
> >
> >     xindiceadmin lc -c /db
> >
> > This will list out your collections.   Looking at the error, it seems to be dying when
> > it trys to query the collection.
> >
> > Mark
> >
> >
> > "Mark J. Stang" wrote:
> >
> > > I have been doing a lot with XUpdate.   It seems to be working fine.   I thought
> > > there was a bug, but it ended up being my XML.
> > >
> > > I compared your code with mine, the only difference that I saw was that your
> > > XUpdate XML has "<?xml version="1.0">.   I only pass in the <xupdate:modifications...>
> > > for the update.   I don't know if that is enough to cause it to die.   Also, anytime
> > > my "xupdate" fails, it does so by not doing the update.   Does the collection exist?
> > > Try using the collection for something more mundane.
> > >
> > > HTH,
> > >
> > > Mark
> > >
> > > The xupdate xml is:
> > > ----------------------------------------------------------
> > > <?xml version="1.0"?>
> > > <xupdate:modifications version="1.0"
> > >        xmlns:xupdate="http://www.xmldb.org/xupdate">
> > >
> > >    <xupdate:insert-before select="/posting/to">
> > >       <xupdate:comment>updated</xupdate:comment>
> > >    </xupdate:insert-before>
> > > </xupdate:modifications>
> > >
> > > Matthew Egbert wrote:
> > >
> > > > Hello,
> > > >
> > > >   I am learning how to use XUpdate with Xindice...Regardless of the
> > > > XUpdate xml, I get the following exception:
> > > >
> > > > org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
> > > >         at
> > > > org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
> > > >         at
> > > > org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
> > > > Source)
> > > >         at
> > > > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
> > > > Source)
> > > >         at
> > > > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
> > > > Source)
> > > >         at XUpdateTest.main(XUpdateTest.java:37)
> > > > XML:DB Exception occured 1 Query Processing Error
> > > >
> > > > The java source is:
> > > > ----------------------------------------------------------
> > > > import org.xmldb.api.base.*;
> > > > import org.xmldb.api.modules.*;
> > > > import org.xmldb.api.*;
> > > > import java.io.FileReader;
> > > > import java.io.BufferedReader;
> > > >
> > > > /**
> > > >  * Simple XML:DB API example to update the database.
> > > >  */
> > > > public class XUpdateTest {
> > > >    public static void main(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:///db/bbs");
> > > >
> > > >          BufferedReader file_reader = new BufferedReader (new
> > > > FileReader(args[0]));
> > > >          String temp;
> > > >          String xupdate=new String();
> > > >
> > > >          temp = file_reader.readLine();
> > > >          while (temp != null) {
> > > >            xupdate=xupdate+temp;
> > > >            temp=file_reader.readLine();
> > > >          }
> > > >
> > > >          System.out.println("\nXUpdate
> > > > Command:\n--------------------------\n"+xupdate+"\n\n\n\n");
> > > >
> > > >          XUpdateQueryService service =
> > > >             (XUpdateQueryService) col.getService("XUpdateQueryService",
> > > > "1.0");
> > > >          service.update(xupdate);
> > > >       }
> > > >       catch (XMLDBException e) {
> > > >          System.err.println("XML:DB Exception occured " + e.errorCode +
> > > > " " +
> > > >             e.getMessage());
> > > >       }
> > > >       finally {
> > > >          if (col != null) {
> > > >             col.close();
> > > >          }
> > > >       }
> > > >    }
> > > > }
> > > >
> > > > The xupdate xml is:
> > > > ----------------------------------------------------------
> > > > <?xml version="1.0"?>
> > > > <xupdate:modifications version="1.0"
> > > >        xmlns:xupdate="http://www.xmldb.org/xupdate">
> > > >
> > > >    <xupdate:insert-before select="/posting/to">
> > > >       <xupdate:comment>updated</xupdate:comment>
> > > >    </xupdate:insert-before>
> > > > </xupdate:modifications>
> > > >
> > > > The output is:
> > > > ----------------------------------------------------------
> > > > $ java XUpdateTest eg_xupdate.xml
> > > >
> > > > XUpdate Command:
> > > > --------------------------
> > > > <?xml version="1.0"?><xupdate:modifications
> > > > version="1.0"       xmlns:xupdate="http://www.xmldb.org/xupdate">
> > > > <xupdate:insert-before select="/posting/to">
> > > > <xupdate:comment>updated</xupdate:comment>
> > > > </xupdate:insert-before></xupdate:modifications>
> > > >
> > > > org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
> > > >         at
> > > > org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
> > > >         at
> > > > org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
> > > > Source)
> > > >         at
> > > > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
> > > > Source)
> > > >         at
> > > > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
> > > > Source)
> > > >         at XUpdateTest.main(XUpdateTest.java:37)
> > > > XML:DB Exception occured 1 Query Processing Error
> > > >
> > > > Does anyone have any suggestions as to where to start looking for the
> > > > problem?  Is this a xindice bug/is XUpdate still in beta?
> > > >
> > > > Cheers,
> > > >
> > > > Matthew
> >
> >


Re: XUpdate

Posted by Matthew Egbert <ma...@epcc.ed.ac.uk>.
Thanks for the speedy reply Mark,

  Unfortunately, it doesn't seem to be the collection that's causing the
problem...

xindiceadmin lc -c /db

locates the collection no prob, and I'm capable of performing:

- XPath queries to the collection
- document submission to the collection
(both via a java application which closely resembles the example apps,
and both without a hitch)

As I've worked with Xindice, axis and tomcat, I have had a few problems
which have been related to the java classpath.  But this doesn't seem to
be that kind of error...am I wrong?  Which packages are to be included in
the classpath to use xupdate (aside from the obvious xmldb.jar)?

Thanks again for the help.


Cheers,


Matthew


On Mon, 4 Mar 2002, Mark J. Stang wrote:

> I love responding to my own e-mail ;-).
> 
> Also, try:
> 
>     xindiceadmin lc -c /db
> 
> This will list out your collections.   Looking at the error, it seems to be dying when
> it trys to query the collection.
> 
> Mark
> 
> 
> "Mark J. Stang" wrote:
> 
> > I have been doing a lot with XUpdate.   It seems to be working fine.   I thought
> > there was a bug, but it ended up being my XML.
> >
> > I compared your code with mine, the only difference that I saw was that your
> > XUpdate XML has "<?xml version="1.0">.   I only pass in the <xupdate:modifications...>
> > for the update.   I don't know if that is enough to cause it to die.   Also, anytime
> > my "xupdate" fails, it does so by not doing the update.   Does the collection exist?
> > Try using the collection for something more mundane.
> >
> > HTH,
> >
> > Mark
> >
> > The xupdate xml is:
> > ----------------------------------------------------------
> > <?xml version="1.0"?>
> > <xupdate:modifications version="1.0"
> >        xmlns:xupdate="http://www.xmldb.org/xupdate">
> >
> >    <xupdate:insert-before select="/posting/to">
> >       <xupdate:comment>updated</xupdate:comment>
> >    </xupdate:insert-before>
> > </xupdate:modifications>
> >
> > Matthew Egbert wrote:
> >
> > > Hello,
> > >
> > >   I am learning how to use XUpdate with Xindice...Regardless of the
> > > XUpdate xml, I get the following exception:
> > >
> > > org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
> > >         at
> > > org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
> > >         at
> > > org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
> > > Source)
> > >         at
> > > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
> > > Source)
> > >         at
> > > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
> > > Source)
> > >         at XUpdateTest.main(XUpdateTest.java:37)
> > > XML:DB Exception occured 1 Query Processing Error
> > >
> > > The java source is:
> > > ----------------------------------------------------------
> > > import org.xmldb.api.base.*;
> > > import org.xmldb.api.modules.*;
> > > import org.xmldb.api.*;
> > > import java.io.FileReader;
> > > import java.io.BufferedReader;
> > >
> > > /**
> > >  * Simple XML:DB API example to update the database.
> > >  */
> > > public class XUpdateTest {
> > >    public static void main(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:///db/bbs");
> > >
> > >          BufferedReader file_reader = new BufferedReader (new
> > > FileReader(args[0]));
> > >          String temp;
> > >          String xupdate=new String();
> > >
> > >          temp = file_reader.readLine();
> > >          while (temp != null) {
> > >            xupdate=xupdate+temp;
> > >            temp=file_reader.readLine();
> > >          }
> > >
> > >          System.out.println("\nXUpdate
> > > Command:\n--------------------------\n"+xupdate+"\n\n\n\n");
> > >
> > >          XUpdateQueryService service =
> > >             (XUpdateQueryService) col.getService("XUpdateQueryService",
> > > "1.0");
> > >          service.update(xupdate);
> > >       }
> > >       catch (XMLDBException e) {
> > >          System.err.println("XML:DB Exception occured " + e.errorCode +
> > > " " +
> > >             e.getMessage());
> > >       }
> > >       finally {
> > >          if (col != null) {
> > >             col.close();
> > >          }
> > >       }
> > >    }
> > > }
> > >
> > > The xupdate xml is:
> > > ----------------------------------------------------------
> > > <?xml version="1.0"?>
> > > <xupdate:modifications version="1.0"
> > >        xmlns:xupdate="http://www.xmldb.org/xupdate">
> > >
> > >    <xupdate:insert-before select="/posting/to">
> > >       <xupdate:comment>updated</xupdate:comment>
> > >    </xupdate:insert-before>
> > > </xupdate:modifications>
> > >
> > > The output is:
> > > ----------------------------------------------------------
> > > $ java XUpdateTest eg_xupdate.xml
> > >
> > > XUpdate Command:
> > > --------------------------
> > > <?xml version="1.0"?><xupdate:modifications
> > > version="1.0"       xmlns:xupdate="http://www.xmldb.org/xupdate">
> > > <xupdate:insert-before select="/posting/to">
> > > <xupdate:comment>updated</xupdate:comment>
> > > </xupdate:insert-before></xupdate:modifications>
> > >
> > > org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
> > >         at
> > > org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
> > >         at
> > > org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
> > > Source)
> > >         at
> > > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
> > > Source)
> > >         at
> > > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
> > > Source)
> > >         at XUpdateTest.main(XUpdateTest.java:37)
> > > XML:DB Exception occured 1 Query Processing Error
> > >
> > > Does anyone have any suggestions as to where to start looking for the
> > > problem?  Is this a xindice bug/is XUpdate still in beta?
> > >
> > > Cheers,
> > >
> > > Matthew
> 
> 


Re: XUpdate

Posted by "Mark J. Stang" <ma...@earthlink.net>.
I love responding to my own e-mail ;-).

Also, try:

    xindiceadmin lc -c /db

This will list out your collections.   Looking at the error, it seems to be dying when
it trys to query the collection.

Mark


"Mark J. Stang" wrote:

> I have been doing a lot with XUpdate.   It seems to be working fine.   I thought
> there was a bug, but it ended up being my XML.
>
> I compared your code with mine, the only difference that I saw was that your
> XUpdate XML has "<?xml version="1.0">.   I only pass in the <xupdate:modifications...>
> for the update.   I don't know if that is enough to cause it to die.   Also, anytime
> my "xupdate" fails, it does so by not doing the update.   Does the collection exist?
> Try using the collection for something more mundane.
>
> HTH,
>
> Mark
>
> The xupdate xml is:
> ----------------------------------------------------------
> <?xml version="1.0"?>
> <xupdate:modifications version="1.0"
>        xmlns:xupdate="http://www.xmldb.org/xupdate">
>
>    <xupdate:insert-before select="/posting/to">
>       <xupdate:comment>updated</xupdate:comment>
>    </xupdate:insert-before>
> </xupdate:modifications>
>
> Matthew Egbert wrote:
>
> > Hello,
> >
> >   I am learning how to use XUpdate with Xindice...Regardless of the
> > XUpdate xml, I get the following exception:
> >
> > org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
> >         at
> > org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
> >         at
> > org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
> > Source)
> >         at
> > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
> > Source)
> >         at
> > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
> > Source)
> >         at XUpdateTest.main(XUpdateTest.java:37)
> > XML:DB Exception occured 1 Query Processing Error
> >
> > The java source is:
> > ----------------------------------------------------------
> > import org.xmldb.api.base.*;
> > import org.xmldb.api.modules.*;
> > import org.xmldb.api.*;
> > import java.io.FileReader;
> > import java.io.BufferedReader;
> >
> > /**
> >  * Simple XML:DB API example to update the database.
> >  */
> > public class XUpdateTest {
> >    public static void main(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:///db/bbs");
> >
> >          BufferedReader file_reader = new BufferedReader (new
> > FileReader(args[0]));
> >          String temp;
> >          String xupdate=new String();
> >
> >          temp = file_reader.readLine();
> >          while (temp != null) {
> >            xupdate=xupdate+temp;
> >            temp=file_reader.readLine();
> >          }
> >
> >          System.out.println("\nXUpdate
> > Command:\n--------------------------\n"+xupdate+"\n\n\n\n");
> >
> >          XUpdateQueryService service =
> >             (XUpdateQueryService) col.getService("XUpdateQueryService",
> > "1.0");
> >          service.update(xupdate);
> >       }
> >       catch (XMLDBException e) {
> >          System.err.println("XML:DB Exception occured " + e.errorCode +
> > " " +
> >             e.getMessage());
> >       }
> >       finally {
> >          if (col != null) {
> >             col.close();
> >          }
> >       }
> >    }
> > }
> >
> > The xupdate xml is:
> > ----------------------------------------------------------
> > <?xml version="1.0"?>
> > <xupdate:modifications version="1.0"
> >        xmlns:xupdate="http://www.xmldb.org/xupdate">
> >
> >    <xupdate:insert-before select="/posting/to">
> >       <xupdate:comment>updated</xupdate:comment>
> >    </xupdate:insert-before>
> > </xupdate:modifications>
> >
> > The output is:
> > ----------------------------------------------------------
> > $ java XUpdateTest eg_xupdate.xml
> >
> > XUpdate Command:
> > --------------------------
> > <?xml version="1.0"?><xupdate:modifications
> > version="1.0"       xmlns:xupdate="http://www.xmldb.org/xupdate">
> > <xupdate:insert-before select="/posting/to">
> > <xupdate:comment>updated</xupdate:comment>
> > </xupdate:insert-before></xupdate:modifications>
> >
> > org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
> >         at
> > org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
> >         at
> > org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
> > Source)
> >         at
> > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
> > Source)
> >         at
> > org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
> > Source)
> >         at XUpdateTest.main(XUpdateTest.java:37)
> > XML:DB Exception occured 1 Query Processing Error
> >
> > Does anyone have any suggestions as to where to start looking for the
> > problem?  Is this a xindice bug/is XUpdate still in beta?
> >
> > Cheers,
> >
> > Matthew


Re: XUpdate

Posted by "Mark J. Stang" <ma...@earthlink.net>.
I have been doing a lot with XUpdate.   It seems to be working fine.   I thought
there was a bug, but it ended up being my XML.

I compared your code with mine, the only difference that I saw was that your
XUpdate XML has "<?xml version="1.0">.   I only pass in the <xupdate:modifications...>
for the update.   I don't know if that is enough to cause it to die.   Also, anytime
my "xupdate" fails, it does so by not doing the update.   Does the collection exist?
Try using the collection for something more mundane.

HTH,

Mark

The xupdate xml is:
----------------------------------------------------------
<?xml version="1.0"?>
<xupdate:modifications version="1.0"
       xmlns:xupdate="http://www.xmldb.org/xupdate">

   <xupdate:insert-before select="/posting/to">
      <xupdate:comment>updated</xupdate:comment>
   </xupdate:insert-before>
</xupdate:modifications>


Matthew Egbert wrote:

> Hello,
>
>   I am learning how to use XUpdate with Xindice...Regardless of the
> XUpdate xml, I get the following exception:
>
> org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
>         at
> org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
>         at
> org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
> Source)
>         at
> org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
> Source)
>         at
> org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
> Source)
>         at XUpdateTest.main(XUpdateTest.java:37)
> XML:DB Exception occured 1 Query Processing Error
>
> The java source is:
> ----------------------------------------------------------
> import org.xmldb.api.base.*;
> import org.xmldb.api.modules.*;
> import org.xmldb.api.*;
> import java.io.FileReader;
> import java.io.BufferedReader;
>
> /**
>  * Simple XML:DB API example to update the database.
>  */
> public class XUpdateTest {
>    public static void main(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:///db/bbs");
>
>          BufferedReader file_reader = new BufferedReader (new
> FileReader(args[0]));
>          String temp;
>          String xupdate=new String();
>
>          temp = file_reader.readLine();
>          while (temp != null) {
>            xupdate=xupdate+temp;
>            temp=file_reader.readLine();
>          }
>
>          System.out.println("\nXUpdate
> Command:\n--------------------------\n"+xupdate+"\n\n\n\n");
>
>          XUpdateQueryService service =
>             (XUpdateQueryService) col.getService("XUpdateQueryService",
> "1.0");
>          service.update(xupdate);
>       }
>       catch (XMLDBException e) {
>          System.err.println("XML:DB Exception occured " + e.errorCode +
> " " +
>             e.getMessage());
>       }
>       finally {
>          if (col != null) {
>             col.close();
>          }
>       }
>    }
> }
>
> The xupdate xml is:
> ----------------------------------------------------------
> <?xml version="1.0"?>
> <xupdate:modifications version="1.0"
>        xmlns:xupdate="http://www.xmldb.org/xupdate">
>
>    <xupdate:insert-before select="/posting/to">
>       <xupdate:comment>updated</xupdate:comment>
>    </xupdate:insert-before>
> </xupdate:modifications>
>
> The output is:
> ----------------------------------------------------------
> $ java XUpdateTest eg_xupdate.xml
>
> XUpdate Command:
> --------------------------
> <?xml version="1.0"?><xupdate:modifications
> version="1.0"       xmlns:xupdate="http://www.xmldb.org/xupdate">
> <xupdate:insert-before select="/posting/to">
> <xupdate:comment>updated</xupdate:comment>
> </xupdate:insert-before></xupdate:modifications>
>
> org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
>         at
> org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
>         at
> org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
> Source)
>         at
> org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
> Source)
>         at
> org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
> Source)
>         at XUpdateTest.main(XUpdateTest.java:37)
> XML:DB Exception occured 1 Query Processing Error
>
> Does anyone have any suggestions as to where to start looking for the
> problem?  Is this a xindice bug/is XUpdate still in beta?
>
> Cheers,
>
> Matthew


XUpdate

Posted by Matthew Egbert <ma...@epcc.ed.ac.uk>.
Hello,

  I am learning how to use XUpdate with Xindice...Regardless of the
XUpdate xml, I get the following exception:

org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
        at
org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
        at
org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
Source)
        at
org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
Source)
        at
org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
Source)
        at XUpdateTest.main(XUpdateTest.java:37)
XML:DB Exception occured 1 Query Processing Error




The java source is:
----------------------------------------------------------
import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;
import java.io.FileReader;
import java.io.BufferedReader;


/**
 * Simple XML:DB API example to update the database.
 */
public class XUpdateTest {
   public static void main(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:///db/bbs");

	 BufferedReader file_reader = new BufferedReader (new
FileReader(args[0]));
	 String temp;
	 String xupdate=new String();      
	 
	 temp = file_reader.readLine();
	 while (temp != null) {
	   xupdate=xupdate+temp;
	   temp=file_reader.readLine();
	 }
	 
	 System.out.println("\nXUpdate
Command:\n--------------------------\n"+xupdate+"\n\n\n\n");
	 
         XUpdateQueryService service =
            (XUpdateQueryService) col.getService("XUpdateQueryService",
"1.0");
         service.update(xupdate);
      }
      catch (XMLDBException e) {
         System.err.println("XML:DB Exception occured " + e.errorCode +
" " +
            e.getMessage());
      }
      finally {
         if (col != null) {
            col.close();
         }
      }
   }
}





The xupdate xml is:
----------------------------------------------------------
<?xml version="1.0"?>
<xupdate:modifications version="1.0"
       xmlns:xupdate="http://www.xmldb.org/xupdate"> 

   <xupdate:insert-before select="/posting/to">
      <xupdate:comment>updated</xupdate:comment>
   </xupdate:insert-before>
</xupdate:modifications>


The output is:
----------------------------------------------------------
$ java XUpdateTest eg_xupdate.xml

XUpdate Command:
--------------------------
<?xml version="1.0"?><xupdate:modifications
version="1.0"       xmlns:xupdate="http://www.xmldb.org/xupdate">
<xupdate:insert-before select="/posting/to">
<xupdate:comment>updated</xupdate:comment>
</xupdate:insert-before></xupdate:modifications>




org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/corba/db/APIException:1.0
        at
org.apache.xindice.client.corba.db.APIExceptionHelper.read(Unknown Source)
        at
org.apache.xindice.client.corba.db._CollectionStub.queryCollection(Unknown
Source)
        at
org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.updateResult(Unknown
Source)
        at
org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.update(Unknown
Source)
        at XUpdateTest.main(XUpdateTest.java:37)
XML:DB Exception occured 1 Query Processing Error






Does anyone have any suggestions as to where to start looking for the
problem?  Is this a xindice bug/is XUpdate still in beta?

Cheers,


Matthew


Re: XPath and attributes

Posted by Richard Hosking <ho...@yahoo.co.uk>.
Yes, I know how to do it from code...  I need to use
XPath though, because the query string is read from a
script file.

Regards,
Richard.

----- Original Message -----
From: "W. Peschke" <Wo...@gmx.ch>
To: <xi...@xml.apache.org>; "'Richard Hosking'" <ho...@yahoo.co.uk>
Sent: Monday, March 04, 2002 12:58 PM
Subject: AW: XPath and attributes


Why don't you use: Collection.getResource( your_wanted_id );
Instead?


Wolfram

-----Ursprüngliche Nachricht-----
Von: Richard Hosking [mailto:hoskingrichard@yahoo.co.uk]
Gesendet: Montag, 4. März 2002 11:55
An: xindice-users@xml.apache.org
Betreff: XPath and attributes


(Using dbXML beta 4, Java 1.4 rc, WinXP)

I'm trying to reference the 'src:key' attribute of the following
document using XPath....

<?xml version="1.0" ?>
<node xmlns:src="http://www.dbxml.org/Query" src:col="/db/root/ocs"
src:key="37005840459e2954000000ec5d2a0272">
</node>

The XPath query i've been trying is...

/node[@src:key = '37005840459e2954000000ec5d2a0272']

and dbXML generates lots of 'debug' exceptions... not very helpful!

DEBUG> javax.xml.transform.TransformerException: Expected ],
but found: '37005840459e2954000000ec5d2a0272'
DEBUG> javax.xml.transform.TransformerException: Extra illegal
tokens: ''37005840459e2954000000ec5d2a0272'', ']'

If I omit the namespace bit 'src:', then no exceptions, but no
documents returned.

Can anyone help?

Regards,
Richard.






AW: XPath and attributes

Posted by "W. Peschke" <Wo...@gmx.ch>.
Why don't you use: Collection.getResource( your_wanted_id );
Instead?


Wolfram

-----Ursprüngliche Nachricht-----
Von: Richard Hosking [mailto:hoskingrichard@yahoo.co.uk] 
Gesendet: Montag, 4. März 2002 11:55
An: xindice-users@xml.apache.org
Betreff: XPath and attributes


(Using dbXML beta 4, Java 1.4 rc, WinXP)

I'm trying to reference the 'src:key' attribute of the following
document using XPath....

<?xml version="1.0" ?> 
<node xmlns:src="http://www.dbxml.org/Query" src:col="/db/root/ocs" 
src:key="37005840459e2954000000ec5d2a0272">
</node>

The XPath query i've been trying is...

/node[@src:key = '37005840459e2954000000ec5d2a0272']

and dbXML generates lots of 'debug' exceptions... not very helpful!

DEBUG> javax.xml.transform.TransformerException: Expected ],
but found: '37005840459e2954000000ec5d2a0272'
DEBUG> javax.xml.transform.TransformerException: Extra illegal
tokens: ''37005840459e2954000000ec5d2a0272'', ']'

If I omit the namespace bit 'src:', then no exceptions, but no
documents returned.

Can anyone help?

Regards,
Richard.