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 Gul Akbar <G....@Bradford.ac.uk> on 2002/12/05 17:58:47 UTC

XPath problem

Hello,

I have this problem with my XPath Query.

//phonebook[ name='Tom' or number='07989270142' ]

This returns the same record twice, and I know that there is only one of those 
records. The XML that is stored:

<phonebook>
<name>Tom</name>
<number>07989270142</number>
</phonebook>

Can anyone please tell me why this record is being returned twice when I use 
the boolean operator "OR" (shown in the XPATH above).

Thanking you in advance
Gul

-------------------------------------------------
This mail sent through IMP: webmail.brad.ac.uk

RE: XPath problem

Posted by Lixin Meng <lx...@yahoo.com>.
The '-v' doesn't produce anything on the console. Btw, my "server" is loaded
with a Tomcat 4.1 servlet. The "client" is from command line. Does the '-v'
from "client" side also turn on debug information of "server" side?

Otherwise, I probably wait your new code.

Lixin

-----Original Message-----
From: Vladimir R. Bossicard [mailto:vladimir@apache.org]
Sent: Monday, December 09, 2002 8:58 AM
To: xindice-users@xml.apache.org
Subject: Re: XPath problem


> Is there any switch that I can turn on the debug or something?

You can try the '-v' commandline option.  Hopefully you'll see something
on your console.

I've changed that on my local version (errors will be automatically
logged) and I hope to commit this change soon.

-Vladimir

--
Vladimir R. Bossicard
Apache Xindice - http://xml.apache.org/xindice


RE: XPath problem

Posted by Lixin Meng <lx...@yahoo.com>.
Thanks.


-----Original Message-----
From: Matthew Van Horn [mailto:horn@accesstech.com]
Sent: Monday, December 09, 2002 6:02 PM
To: xindice-users@xml.apache.org
Subject: Re: XPath problem



On Tuesday, December 10, 2002, at 03:22 AM, Lixin Meng wrote:


> FYI.
> - I tried to trace the code, but could NOT reproduce the problem with
> *embedded* version. The problem happened when the server was loaded 
> with
> servlet and client was from Windows command line.
> - I tried to search which file contains string "was unexpected at this
> time", NO return either.
>
> Does this mean it is something related to how Windows interprets the 
> command
> line again? Anyone has a Unix OS can do a simple experiment like 
> following?
>
> 	xindice xpath_query -c /db/testing -q "/data/test2[@forTest2 = '1']"

Works fine for me (OS X / tcsh).
Sounds like a problem with the windows shell. No big surprise there.

Re: XPath problem

Posted by Matthew Van Horn <ho...@accesstech.com>.
On Tuesday, December 10, 2002, at 03:22 AM, Lixin Meng wrote:


> FYI.
> - I tried to trace the code, but could NOT reproduce the problem with
> *embedded* version. The problem happened when the server was loaded 
> with
> servlet and client was from Windows command line.
> - I tried to search which file contains string "was unexpected at this
> time", NO return either.
>
> Does this mean it is something related to how Windows interprets the 
> command
> line again? Anyone has a Unix OS can do a simple experiment like 
> following?
>
> 	xindice xpath_query -c /db/testing -q "/data/test2[@forTest2 = '1']"

Works fine for me (OS X / tcsh).
Sounds like a problem with the windows shell. No big surprise there.


RE: XPath problem

Posted by Lixin Meng <lx...@yahoo.com>.
FYI.
- I tried to trace the code, but could NOT reproduce the problem with
*embedded* version. The problem happened when the server was loaded with
servlet and client was from Windows command line.
- I tried to search which file contains string "was unexpected at this
time", NO return either.

Does this mean it is something related to how Windows interprets the command
line again? Anyone has a Unix OS can do a simple experiment like following?

	xindice xpath_query -c /db/testing -q "/data/test2[@forTest2 = '1']"

The query is not important, only the space before and after '='. If you can
get something back with error message, it might validate the assumption.

Lixin

-----Original Message-----
From: Vladimir R. Bossicard [mailto:vladimir@apache.org]
Sent: Monday, December 09, 2002 8:58 AM
To: xindice-users@xml.apache.org
Subject: Re: XPath problem


> Is there any switch that I can turn on the debug or something?

You can try the '-v' commandline option.  Hopefully you'll see something
on your console.

I've changed that on my local version (errors will be automatically
logged) and I hope to commit this change soon.

-Vladimir

--
Vladimir R. Bossicard
Apache Xindice - http://xml.apache.org/xindice


Re: XPath problem

Posted by "Vladimir R. Bossicard" <vl...@apache.org>.
> Is there any switch that I can turn on the debug or something?

You can try the '-v' commandline option.  Hopefully you'll see something 
on your console.

I've changed that on my local version (errors will be automatically 
logged) and I hope to commit this change soon.

-Vladimir

-- 
Vladimir R. Bossicard
Apache Xindice - http://xml.apache.org/xindice



RE: XPath problem

Posted by Lixin Meng <lx...@yahoo.com>.
I run it from command line. There is no stackstrace. 

Is there any switch that I can turn on the debug or something?

Lixin

-----Original Message-----
From: Vladimir R. Bossicard [mailto:vladimir@apache.org]
Sent: Friday, December 06, 2002 11:59 AM
To: xindice-users@xml.apache.org
Subject: Re: XPath problem


> will get an error message:
> 
> 	= was unexpected at this time.

Do you have a stacktrace so that I can see exactly where the problem is? 
  Otherwise it's really time-consuming to find out where exactly the 
problem is.

Thanks,

-Vladimir

-- 
Vladimir R. Bossicard
Apache Xindice - http://xml.apache.org/xindice


Re: XPath problem

Posted by "Vladimir R. Bossicard" <vl...@apache.org>.
> will get an error message:
> 
> 	= was unexpected at this time.

Do you have a stacktrace so that I can see exactly where the problem is? 
  Otherwise it's really time-consuming to find out where exactly the 
problem is.

Thanks,

-Vladimir

-- 
Vladimir R. Bossicard
Apache Xindice - http://xml.apache.org/xindice



Re: Embedding Xindice

Posted by Emiliano <em...@iris-advies.nl>.
Vladimir R. Bossicard wrote:

> > How much agony am I going to get
> > if I set that property to ServletContext.getRealPath("/WEB-INF/Xindice")?
>
> Xindice is not meant to be only run within a servlet-container: i.e.
> there won't be any reference to the ServletContext in the core Xindice
> code (embed/xml-rpc drivers).
>
> But you can still change that in your local version.  Simply don't
> expect your changes to be integrated into further versions.

I don't think I'm expressing myself clearly... I don't want this Xindice
to be accessible by the outside world. I would only use it from within
my app (which just happens to be a servlet... I don't think it'll make a
difference to the embedded Xindice) to store, retrieve and query XML
data.

Emile


Re: Embedding Xindice

Posted by "Vladimir R. Bossicard" <vl...@apache.org>.
> How much agony am I going to get
> if I set that property to ServletContext.getRealPath("/WEB-INF/Xindice")?

Xindice is not meant to be only run within a servlet-container: i.e. 
there won't be any reference to the ServletContext in the core Xindice 
code (embed/xml-rpc drivers).

But you can still change that in your local version.  Simply don't 
expect your changes to be integrated into further versions.

Regards,

-Vladimir

-- 
Vladimir R. Bossicard
Apache Xindice - http://xml.apache.org/xindice



Re: Embedding Xindice

Posted by Emiliano <em...@iris-advies.nl>.
Mark Eggers wrote:

> However, this looks like it can be changed by editing
> a system.xml file found in the WEB-INF directory of
> the unpacked Xindice.war file.  I am not quite sure
> how it translates the default ./db/ to
> C:\WINNT\system32\db, but it does.

Looks like Database.java prefixes the DB directory with
a System property PROP_XINDICE_HOME(="xindice.home") when it
is a relative directory. How much agony am I going to get
if I set that property to ServletContext.getRealPath("/WEB-INF/Xindice")?
Is it used for much else? And when/how do I set it anyway?

Emile


Re: Embedding Xindice

Posted by Emiliano <em...@iris-advies.nl>.
Mark Eggers wrote:

> > Hardcoding a
> > full path is going to make for annoying deployment
> > hassles.
>
> Agreed - and cross-operating system support will be
> especially tricky.
>
> I guess it's time to look at the code and make a
> recommendation?

I'm studying Database.java, and looking at the driver key... wondering
if I can just force this "xmldb:xindice-embed://db" to include a fully
qualified filepath (determined at runtime) to stop Database.java from
qualifying it by itself.

Emile



Re: Embedding Xindice

Posted by Emiliano <em...@iris-advies.nl>.
Mark Eggers wrote:

> I guess it's time to look at the code and make a
> recommendation?

Why oh why does this keep happening to me? I pick up some tech to save
me some time, next thing I know I'm on the -dev list :)

Emile


Re: Embedding Xindice

Posted by Mark Eggers <it...@yahoo.com>.
--- Emiliano <em...@iris-advies.nl> wrote:
> Hardcoding a
> full path is going to make for annoying deployment
> hassles.

Agreed - and cross-operating system support will be
especially tricky.

I guess it's time to look at the code and make a
recommendation?

/mde/

just my two cents . . . .

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Re: Embedding Xindice

Posted by Emiliano <em...@iris-advies.nl>.
Mark Eggers wrote:

> However, this looks like it can be changed by editing
> a system.xml file found in the WEB-INF directory of
> the unpacked Xindice.war file.  I am not quite sure
> how it translates the default ./db/ to
> C:\WINNT\system32\db, but it does.
>
> I'm thinking a fully specified path will allow you to
> put the collection where you would like, but I have
> not experimented with this.

I'll have to go experiment... but this doesn't exactly sound all too
encouraging. I want the database to be WEB-INF - relative. Hardcoding a
full path is going to make for annoying deployment hassles.

Emile


Re: Embedding Xindice

Posted by Mark Eggers <it...@yahoo.com>.
--- Emiliano <em...@iris-advies.nl> wrote:

> The thing I'm still unsure about is that I saw a 
> mention on the list a while ago that the database
had > to live in the directory Xindice was started
in.... 
> which would be where tomcat was started in case I
> embed Xindice.

There was some discussion about where the Xindice db
collection resides for the 1.1 version.  It turns out
that the collection resides in the WINNT\system32
directory (on Windows/2000 Pro) by default.

However, this looks like it can be changed by editing
a system.xml file found in the WEB-INF directory of
the unpacked Xindice.war file.  I am not quite sure
how it translates the default ./db/ to
C:\WINNT\system32\db, but it does.

I'm thinking a fully specified path will allow you to
put the collection where you would like, but I have
not experimented with this.

/mde/

just my two cents . . . .

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Re: Embedding Xindice

Posted by Emiliano <em...@iris-advies.nl>.
Ross Gardler wrote:

> > I have been perusing the ML archives, and google, but while I can find
> > enough statements that Xindice can be embedded, I cannot actually find
> > any onfo on *how* to embed Xindice. Could somebody please:
> >
> > * thwack me on the head and point me to TFM so I can R it
>
> No idea if there is a manual entry specilifacally for this but I happend
> to spot embedded deep in a mail somewhere...
>
> Basically just access the DB with the URI "xmldb:xindice-embed://db"
>
> If you search the mail archives for that string you should find some
> sample code plus all examples in the docs work the same way

Thank you. Will try.

> > I'm looking to embed this into a servlet, so the database file(s) would
> > have to live in WEB-INF I guess.
>
> I guess you'r right, not done it myself but as long as the xindice stuff
> is in the classpath (i.e. WEB-INF/lib) can't see why it wouldn't work.

The thing I'm still unsure about is that I saw a mention on the list a
while ago that the database had to live in the directory Xindice
was started in.... which would be where tomcat was started in case I
embed Xindice. That won't work. I hope I'm wrong about this.

Emile


Re: Embedding Xindice

Posted by Emiliano <em...@iris-advies.nl>.
Ross Gardler wrote:

> Basically just access the DB with the URI "xmldb:xindice-embed://db"
>
> If you search the mail archives for that string you should find some
> sample code plus all examples in the docs work the same way

Been doing this... I found lots more info (thanks) but this one thing
worries me:

> Subject:  AW: Embedded version with the cvs version
> From:     "Dirk Bromberg" <br...@tzi.de>
> Date:     2002-09-04 18:16:04
>
> Collection myCol =
> DatabaseManager.getCollection("xmldb:xindice-embed:///db/");
>
> but the driver is not stable

Does anyone know what the current status of the driver is? Or know if
eXist would be a better option for the time being while the driver
stabilizes?

Emile


Re: Embedding Xindice

Posted by Ross Gardler <ro...@saafe.org>.

Emiliano wrote:
> Hi all,
> 
> I have been perusing the ML archives, and google, but while I can find
> enough statements that Xindice can be embedded, I cannot actually find
> any onfo on *how* to embed Xindice. Could somebody please:
> 
> * thwack me on the head and point me to TFM so I can R it

No idea if there is a manual entry specilifacally for this but I happend 
to spot embedded deep in a mail somewhere...

Basically just access the DB with the URI "xmldb:xindice-embed://db"

If you search the mail archives for that string you should find some 
sample code plus all examples in the docs work the same way

> * provide a simple HOWTO, or
> * provide some sample code?
> 
> I'm looking to embed this into a servlet, so the database file(s) would
> have to live in WEB-INF I guess.

I guess you'r right, not done it myself but as long as the xindice stuff 
is in the classpath (i.e. WEB-INF/lib) can't see why it wouldn't work.

Ross

> 
> TIA,
> Emile



Embedding Xindice

Posted by Emiliano <em...@iris-advies.nl>.
Hi all,

I have been perusing the ML archives, and google, but while I can find
enough statements that Xindice can be embedded, I cannot actually find
any onfo on *how* to embed Xindice. Could somebody please:

* thwack me on the head and point me to TFM so I can R it
* provide a simple HOWTO, or
* provide some sample code?

I'm looking to embed this into a servlet, so the database file(s) would
have to live in WEB-INF I guess.

TIA,
Emile


RE: XPath problem

Posted by Lixin Meng <lx...@yahoo.com>.
As for the reference to an attribute, the return doesn't has to be a
attribute of some element. It could be just the value, as the implementation
used in XSLT. Right?

Is there any documentation on the difference between the XPath supported by
Xindice and the XPath standard?

Again, thanks for the help and I hope you will do well with your other
deadlines.

Lixin

-----Original Message-----
From: Matthew Van Horn [mailto:horn@accesstech.com]
Sent: Thursday, December 05, 2002 10:02 PM
To: xindice-users@xml.apache.org
Subject: Re: XPath problem



On Friday, December 6, 2002, at 01:59 PM, Lixin Meng wrote:

> 	xindice xpath_query -c /db/testing -q "/data/test2[@forTest2 = '1']"
>
> will get an error message:
>
> 	= was unexpected at this time.
>
> Any idea why the white space matters? Also, is there any plan for
> returning
> attributes?
>
Sounds to me like a bug. That might be a good excuse for someone to
look at the source code, and see aboud contributing a fix. (It won't be
me, at least until I meet my other deadlines ;-)

I think there is a fundamental problem with returning attributes, as
they have to be attributes *of some element*
You may want to rethink your schema, (as I had to do recently) to deal
with the problem.

> Again, appreciate your help.
>
> Lixin
>
> -----Original Message-----
> From: Matthew Van Horn [mailto:horn@accesstech.com]
> Sent: Thursday, December 05, 2002 7:02 PM
> To: xindice-users@xml.apache.org
> Subject: Re: XPath problem
>
>
>
> On Friday, December 6, 2002, at 12:00 PM, Matthew Van Horn wrote:
>>
>> 1. Xindice will NOT return attributes, only elements.
>> xindice xpath_query -c /db/testing -q /data/test2/forTest2 **will not
>> work
>>
>> 2. use quotes around your query when using the command line, otherwise
>> the shell tends to screw things up - especially with quote and
>> parentheses characters. It's easier to use quotes than to escape
>> everything that needs to be escaped.
>> xindice xpath_query -c /db/testing -q "/data/test2[forTest2 = '1']"
>>
>>
> and I forgot - the query should be: "/data/test2[@forTest2 = '1']"
>                                                   ^denotes attribute
>


Re: XPath problem

Posted by Matthew Van Horn <ho...@accesstech.com>.
On Friday, December 6, 2002, at 01:59 PM, Lixin Meng wrote:

> 	xindice xpath_query -c /db/testing -q "/data/test2[@forTest2 = '1']"
>
> will get an error message:
>
> 	= was unexpected at this time.
>
> Any idea why the white space matters? Also, is there any plan for 
> returning
> attributes?
>
Sounds to me like a bug. That might be a good excuse for someone to 
look at the source code, and see aboud contributing a fix. (It won't be 
me, at least until I meet my other deadlines ;-)

I think there is a fundamental problem with returning attributes, as 
they have to be attributes *of some element*
You may want to rethink your schema, (as I had to do recently) to deal 
with the problem.

> Again, appreciate your help.
>
> Lixin
>
> -----Original Message-----
> From: Matthew Van Horn [mailto:horn@accesstech.com]
> Sent: Thursday, December 05, 2002 7:02 PM
> To: xindice-users@xml.apache.org
> Subject: Re: XPath problem
>
>
>
> On Friday, December 6, 2002, at 12:00 PM, Matthew Van Horn wrote:
>>
>> 1. Xindice will NOT return attributes, only elements.
>> xindice xpath_query -c /db/testing -q /data/test2/forTest2 **will not
>> work
>>
>> 2. use quotes around your query when using the command line, otherwise
>> the shell tends to screw things up - especially with quote and
>> parentheses characters. It's easier to use quotes than to escape
>> everything that needs to be escaped.
>> xindice xpath_query -c /db/testing -q "/data/test2[forTest2 = '1']"
>>
>>
> and I forgot - the query should be: "/data/test2[@forTest2 = '1']"
>                                                   ^denotes attribute
>


RE: XPath problem

Posted by Lixin Meng <lx...@yahoo.com>.
Matthew,

Thanks for the help.

By the way,

	xindice xpath_query -c /db/testing -q "/data/test2[@forTest2='1']"

works, but

	xindice xpath_query -c /db/testing -q "/data/test2[@forTest2 = '1']"

will get an error message:

	= was unexpected at this time.

Any idea why the white space matters? Also, is there any plan for returning
attributes?

Again, appreciate your help.

Lixin

-----Original Message-----
From: Matthew Van Horn [mailto:horn@accesstech.com]
Sent: Thursday, December 05, 2002 7:02 PM
To: xindice-users@xml.apache.org
Subject: Re: XPath problem



On Friday, December 6, 2002, at 12:00 PM, Matthew Van Horn wrote:
>
> 1. Xindice will NOT return attributes, only elements.
> xindice xpath_query -c /db/testing -q /data/test2/forTest2 **will not
> work
>
> 2. use quotes around your query when using the command line, otherwise
> the shell tends to screw things up - especially with quote and
> parentheses characters. It's easier to use quotes than to escape
> everything that needs to be escaped.
> xindice xpath_query -c /db/testing -q "/data/test2[forTest2 = '1']"
>
>
and I forgot - the query should be: "/data/test2[@forTest2 = '1']"
                                                  ^denotes attribute


Re: XPath problem

Posted by Matthew Van Horn <ho...@accesstech.com>.
On Friday, December 6, 2002, at 12:00 PM, Matthew Van Horn wrote:
>
> 1. Xindice will NOT return attributes, only elements.
> xindice xpath_query -c /db/testing -q /data/test2/forTest2 **will not 
> work
>
> 2. use quotes around your query when using the command line, otherwise 
> the shell tends to screw things up - especially with quote and 
> parentheses characters. It's easier to use quotes than to escape 
> everything that needs to be escaped.
> xindice xpath_query -c /db/testing -q "/data/test2[forTest2 = '1']"
>
>
and I forgot - the query should be: "/data/test2[@forTest2 = '1']"
                                                  ^denotes attribute


Re: XPath problem

Posted by Matthew Van Horn <ho...@accesstech.com>.
On Friday, December 6, 2002, at 11:51 AM, Lixin Meng wrote:
> I also did test as
>
> 	xindice xpath_query -c /db/testing -q /data/test2/forTest2
>
> This time, there is no return. ???
>
> If I try anything like
>
> 	xindice xpath_query -c /db/testing -q /data[position() = '1']
> 		or
> 	xindice xpath_query -c /db/testing -q /data/test2[forTest2 = '1']
>
> I will get error message:

1. Xindice will NOT return attributes, only elements.
xindice xpath_query -c /db/testing -q /data/test2/forTest2 **will not 
work

2. use quotes around your query when using the command line, otherwise 
the shell tends to screw things up - especially with quote and 
parentheses characters. It's easier to use quotes than to escape 
everything that needs to be escaped.
xindice xpath_query -c /db/testing -q "/data/test2[forTest2 = '1']"



RE: XPath problem

Posted by Lixin Meng <lx...@yahoo.com>.
Another case related to XPath, but I am not sure it is related to the same
problem posted above.

I have a very small collection (only two documents). If I issue:

	xindice xpath_query -c /db/testing -q /data

I got two records:

  <data src:col="/db/testing" src:key="doc1"
xmlns:src="http://xml.apache.org/xindice/Query">
    <test xmlns:src="http://xml.apache.org/xindice/Query">test data</test>
  </data>
  <data src:col="/db/testing" src:key="doc2"
xmlns:src="http://xml.apache.org/xindice/Query">
    <test2 forTest2="1" xmlns:src="http://xml.apache.org/xindice/Query">test
data 2</test2>
  </data>

However, if I change query to

	xindice xpath_query -c /db/testing -q /data[1]

It still returned above two records. Shouldn't it only return one?

I also did test as

	xindice xpath_query -c /db/testing -q /data/test2/forTest2

This time, there is no return. ???

If I try anything like

	xindice xpath_query -c /db/testing -q /data[position() = '1']
		or
	xindice xpath_query -c /db/testing -q /data/test2[forTest2 = '1']

I will get error message:

	ERROR : Query error: java.lang.Exception:
		org.apache.xindice.core.query.CompilationException: Error Compiling XPath
Expression

Does anybody have any idea where should I look into?

By the way, I am using 1.1b with Tomcat 4.1 on Win2K.

Lixin


-----Original Message-----
From: Todd Byrne [mailto:byrne@cns.montana.edu]
Sent: Thursday, December 05, 2002 1:47 PM
To: xindice-users@xml.apache.org
Subject: Re: XPath problem


Hi Gul,

I ran your query from the command line on your sample document in a test
database and it only returned one record like I expected.  Are you sure
this record isn't in more then one document or repeated in your
document?

here is the command I ran: xindice xpath -c /db/test -q
"//phonebook[name='Tom' or number='07989270142']"

and my output:
<?xml version="1.0"?>
<phonebook xmlns:src="http://xml.apache.org/xindice/Query"
src:col="/db/test" src:key="test">
<name>Tom</name>
<number>07989270142</number>
</phonebook>

I am using version 1.0 still.

Maybe you can discribe your problem in a tad more depth and I would be
glad to continue to help.

Todd Byrne

On Thu, 2002-12-05 at 09:58, Gul Akbar wrote:
> Hello,
>
> I have this problem with my XPath Query.
>
> //phonebook[ name='Tom' or number='07989270142' ]
>
> This returns the same record twice, and I know that there is only one of
those
> records. The XML that is stored:
>
> <phonebook>
> <name>Tom</name>
> <number>07989270142</number>
> </phonebook>
>
> Can anyone please tell me why this record is being returned twice when I
use
> the boolean operator "OR" (shown in the XPATH above).
>
> Thanking you in advance
> Gul
>
> -------------------------------------------------
> This mail sent through IMP: webmail.brad.ac.uk


Question

Posted by Alex Mariano Costa de Oliveira <ma...@inf.ufsc.br>.
I would like to know whether exists any brazilian member in this list? If
so, please contact me.

Regards
Alex Mariano



Re: XPath problem

Posted by Todd Byrne <by...@cns.montana.edu>.
Hi Gul,

Glad I could help.

No exception will be thrown because if you add the document with out a
user generated key then xinidce generates a unquie key for the document.
But if you add the same document with the same name then xindice just
overwrites the old document with the new document.

Todd
On Fri, 2002-12-06 at 16:19, Gul Akbar wrote:
> I have found what my problem is. It is to do with my servlet and NOT Xindice.
> I call the method which adds the record to the database TWICE. So basically 
> there are two records stored in the database.
> 
> Is there a way in which Xindice reports an exception if the same records is 
> being added twice; i.e. primary key in relational databases?
> 
> Thanks for your help
> Gul
> 
> 
> 
> Quoting Gul Akbar <G....@Bradford.ac.uk>:
> 
> > Todd,
> > 
> > I actually use a Java servlet to access the database. The code below is
> > what I 
> > used (I found this code on the website):
> > 
> > -----------------------------------
> > 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/phonebook");
> > 
> >  String xpath = "//phonebook[name='Tom' and number='07989270142']";
> > 
> > 
> >  XPathQueryService service = (XPathQueryService) col.getService
> > ("XPathQueryService", "1.0");
> >  ResourceSet resultSet = service.query(xpath);
> >  ResourceIterator results = resultSet.getIterator();
> > 
> >  while (results.hasMoreResources()) {
> >    Resource res = results.nextResource();
> >    String outcome = (String) res.getContent();
> >    System.out.println(outcome)
> >    }//while
> > 
> > }//try
> > catch (XMLDBException e) {
> >  System.err.println("XML:DB Exception occured " + e.getMessage());
> >  }//catch
> > catch (Exception ie) {
> >  System.err.println("XML:DB Exception occured " + ie.getMessage());
> >  }//catch
> > 
> > -----------------------------------
> > 
> > I use this in a class which my servlet calls. It works fine in some
> > respect. I 
> > can search for everything in the database, and it returns null if no
> > records 
> > have been found. However, using the OR operator, it returns the same
> > record 
> > twice.
> > Can you see what the problem might be?
> > 
> > 
> > Thanks
> > Gul
> > 
> > 
> > 
> > 
> > Quoting Todd Byrne <by...@cns.montana.edu>:
> > 
> > > Hi Gul,
> > > 
> > > I ran your query from the command line on your sample document in a
> > > test
> > > database and it only returned one record like I expected.  Are you
> > > sure
> > > this record isn't in more then one document or repeated in your
> > > document?
> > > 
> > > here is the command I ran: xindice xpath -c /db/test -q
> > > "//phonebook[name='Tom' or number='07989270142']"
> > > 
> > > and my output:
> > > <?xml version="1.0"?>
> > > <phonebook xmlns:src="http://xml.apache.org/xindice/Query"
> > > src:col="/db/test" src:key="test">
> > > <name>Tom</name>
> > > <number>07989270142</number>
> > > </phonebook>
> > > 
> > > I am using version 1.0 still.  
> > > 
> > > Maybe you can discribe your problem in a tad more depth and I would
> > be
> > > glad to continue to help.
> > > 
> > > Todd Byrne
> > > 
> > > On Thu, 2002-12-05 at 09:58, Gul Akbar wrote:
> > > > Hello,
> > > > 
> > > > I have this problem with my XPath Query.
> > > > 
> > > > //phonebook[ name='Tom' or number='07989270142' ]
> > > > 
> > > > This returns the same record twice, and I know that there is only
> > one
> > > of those 
> > > > records. The XML that is stored:
> > > > 
> > > > <phonebook>
> > > > <name>Tom</name>
> > > > <number>07989270142</number>
> > > > </phonebook>
> > > > 
> > > > Can anyone please tell me why this record is being returned twice
> > when
> > > I use 
> > > > the boolean operator "OR" (shown in the XPATH above).
> > > > 
> > > > Thanking you in advance
> > > > Gul
> > > > 
> > > > -------------------------------------------------
> > > > This mail sent through IMP: webmail.brad.ac.uk
> > > 
> > > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -------------------------------------------------
> > This mail sent through IMP: webmail.brad.ac.uk
> > 
> 
> 
> 
> 
> 
> 
> -------------------------------------------------
> This mail sent through IMP: webmail.brad.ac.uk


Re: XPath problem

Posted by Gul Akbar <G....@Bradford.ac.uk>.
I have found what my problem is. It is to do with my servlet and NOT Xindice.
I call the method which adds the record to the database TWICE. So basically 
there are two records stored in the database.

Is there a way in which Xindice reports an exception if the same records is 
being added twice; i.e. primary key in relational databases?

Thanks for your help
Gul



Quoting Gul Akbar <G....@Bradford.ac.uk>:

> Todd,
> 
> I actually use a Java servlet to access the database. The code below is
> what I 
> used (I found this code on the website):
> 
> -----------------------------------
> 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/phonebook");
> 
>  String xpath = "//phonebook[name='Tom' and number='07989270142']";
> 
> 
>  XPathQueryService service = (XPathQueryService) col.getService
> ("XPathQueryService", "1.0");
>  ResourceSet resultSet = service.query(xpath);
>  ResourceIterator results = resultSet.getIterator();
> 
>  while (results.hasMoreResources()) {
>    Resource res = results.nextResource();
>    String outcome = (String) res.getContent();
>    System.out.println(outcome)
>    }//while
> 
> }//try
> catch (XMLDBException e) {
>  System.err.println("XML:DB Exception occured " + e.getMessage());
>  }//catch
> catch (Exception ie) {
>  System.err.println("XML:DB Exception occured " + ie.getMessage());
>  }//catch
> 
> -----------------------------------
> 
> I use this in a class which my servlet calls. It works fine in some
> respect. I 
> can search for everything in the database, and it returns null if no
> records 
> have been found. However, using the OR operator, it returns the same
> record 
> twice.
> Can you see what the problem might be?
> 
> 
> Thanks
> Gul
> 
> 
> 
> 
> Quoting Todd Byrne <by...@cns.montana.edu>:
> 
> > Hi Gul,
> > 
> > I ran your query from the command line on your sample document in a
> > test
> > database and it only returned one record like I expected.  Are you
> > sure
> > this record isn't in more then one document or repeated in your
> > document?
> > 
> > here is the command I ran: xindice xpath -c /db/test -q
> > "//phonebook[name='Tom' or number='07989270142']"
> > 
> > and my output:
> > <?xml version="1.0"?>
> > <phonebook xmlns:src="http://xml.apache.org/xindice/Query"
> > src:col="/db/test" src:key="test">
> > <name>Tom</name>
> > <number>07989270142</number>
> > </phonebook>
> > 
> > I am using version 1.0 still.  
> > 
> > Maybe you can discribe your problem in a tad more depth and I would
> be
> > glad to continue to help.
> > 
> > Todd Byrne
> > 
> > On Thu, 2002-12-05 at 09:58, Gul Akbar wrote:
> > > Hello,
> > > 
> > > I have this problem with my XPath Query.
> > > 
> > > //phonebook[ name='Tom' or number='07989270142' ]
> > > 
> > > This returns the same record twice, and I know that there is only
> one
> > of those 
> > > records. The XML that is stored:
> > > 
> > > <phonebook>
> > > <name>Tom</name>
> > > <number>07989270142</number>
> > > </phonebook>
> > > 
> > > Can anyone please tell me why this record is being returned twice
> when
> > I use 
> > > the boolean operator "OR" (shown in the XPATH above).
> > > 
> > > Thanking you in advance
> > > Gul
> > > 
> > > -------------------------------------------------
> > > This mail sent through IMP: webmail.brad.ac.uk
> > 
> > 
> 
> 
> 
> 
> 
> 
> -------------------------------------------------
> This mail sent through IMP: webmail.brad.ac.uk
> 






-------------------------------------------------
This mail sent through IMP: webmail.brad.ac.uk

Re: XPath problem

Posted by Gul Akbar <G....@Bradford.ac.uk>.
Todd,

I actually use a Java servlet to access the database. The code below is what I 
used (I found this code on the website):

-----------------------------------
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/phonebook");

 String xpath = "//phonebook[name='Tom' and number='07989270142']";


 XPathQueryService service = (XPathQueryService) col.getService
("XPathQueryService", "1.0");
 ResourceSet resultSet = service.query(xpath);
 ResourceIterator results = resultSet.getIterator();

 while (results.hasMoreResources()) {
   Resource res = results.nextResource();
   String outcome = (String) res.getContent();
   System.out.println(outcome)
   }//while

}//try
catch (XMLDBException e) {
 System.err.println("XML:DB Exception occured " + e.getMessage());
 }//catch
catch (Exception ie) {
 System.err.println("XML:DB Exception occured " + ie.getMessage());
 }//catch

-----------------------------------

I use this in a class which my servlet calls. It works fine in some respect. I 
can search for everything in the database, and it returns null if no records 
have been found. However, using the OR operator, it returns the same record 
twice.
Can you see what the problem might be?


Thanks
Gul




Quoting Todd Byrne <by...@cns.montana.edu>:

> Hi Gul,
> 
> I ran your query from the command line on your sample document in a
> test
> database and it only returned one record like I expected.  Are you
> sure
> this record isn't in more then one document or repeated in your
> document?
> 
> here is the command I ran: xindice xpath -c /db/test -q
> "//phonebook[name='Tom' or number='07989270142']"
> 
> and my output:
> <?xml version="1.0"?>
> <phonebook xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test" src:key="test">
> <name>Tom</name>
> <number>07989270142</number>
> </phonebook>
> 
> I am using version 1.0 still.  
> 
> Maybe you can discribe your problem in a tad more depth and I would be
> glad to continue to help.
> 
> Todd Byrne
> 
> On Thu, 2002-12-05 at 09:58, Gul Akbar wrote:
> > Hello,
> > 
> > I have this problem with my XPath Query.
> > 
> > //phonebook[ name='Tom' or number='07989270142' ]
> > 
> > This returns the same record twice, and I know that there is only one
> of those 
> > records. The XML that is stored:
> > 
> > <phonebook>
> > <name>Tom</name>
> > <number>07989270142</number>
> > </phonebook>
> > 
> > Can anyone please tell me why this record is being returned twice when
> I use 
> > the boolean operator "OR" (shown in the XPATH above).
> > 
> > Thanking you in advance
> > Gul
> > 
> > -------------------------------------------------
> > This mail sent through IMP: webmail.brad.ac.uk
> 
> 






-------------------------------------------------
This mail sent through IMP: webmail.brad.ac.uk

Re: XPath problem

Posted by Todd Byrne <by...@cns.montana.edu>.
Hi Gul,

I ran your query from the command line on your sample document in a test
database and it only returned one record like I expected.  Are you sure
this record isn't in more then one document or repeated in your
document?

here is the command I ran: xindice xpath -c /db/test -q
"//phonebook[name='Tom' or number='07989270142']"

and my output:
<?xml version="1.0"?>
<phonebook xmlns:src="http://xml.apache.org/xindice/Query"
src:col="/db/test" src:key="test">
<name>Tom</name>
<number>07989270142</number>
</phonebook>

I am using version 1.0 still.  

Maybe you can discribe your problem in a tad more depth and I would be
glad to continue to help.

Todd Byrne

On Thu, 2002-12-05 at 09:58, Gul Akbar wrote:
> Hello,
> 
> I have this problem with my XPath Query.
> 
> //phonebook[ name='Tom' or number='07989270142' ]
> 
> This returns the same record twice, and I know that there is only one of those 
> records. The XML that is stored:
> 
> <phonebook>
> <name>Tom</name>
> <number>07989270142</number>
> </phonebook>
> 
> Can anyone please tell me why this record is being returned twice when I use 
> the boolean operator "OR" (shown in the XPATH above).
> 
> Thanking you in advance
> Gul
> 
> -------------------------------------------------
> This mail sent through IMP: webmail.brad.ac.uk


Question about Document Key

Posted by "Dr. Klemens Waldhör" <Wa...@t-online.de>.
Hi,

Two questions:

A) Are there any restrictions on the characters which can be used for
the document key? Can all ANSI or ASCII chars be used?
B) Are there any restrictions on the length of the document key?

Thanks.

Klemens


Re: XPath problem

Posted by "Vladimir R. Bossicard" <vb...@yahoo.com>.
> I would have thought this is amongst one of the important aspects of a
> database.

you're right, but it's still difficult to have a product without bugs. 
Xindice is relatively young and it still has to mature and correct his
defaults.

> I was also wondering what the CVS versions (I think thats what they called)
> are for.

more infos on <http://xml.apache.org/overview.html>

> I am going to use Xindice for my final year project at university, and this
> is a main drawback. What happens after I report the bug? How long does
> it take

well since Xindice is a volunteer project (i.e. people are not paid for that)
you'll have to wait until one volunteer offers his time to fix your problem. 
The ideal solution is if you can fix the bug yourself.  Otherwise you'll have
to wait.

-Vladimir

=====
Vladimir R. Bossicard
Apache Xindice - http://xml.apache.org/xindice

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Re: XPath problem

Posted by Gul Akbar <G....@Bradford.ac.uk>.
Hello,

I would have thought this is amongst one of the important aspects of a database.
I was also wondering what the CVS versions (I think thats what they called) are 
for.
I am going to use Xindice for my final year project at university, and this is 
a main drawback. What happens after I report the bug? How long does it take 
etc..

Thanks again
Gul



Quoting "Vladimir R. Bossicard" <vb...@yahoo.com>:

> > Can anyone please tell me why this record is being returned twice when
> I
> > use the boolean operator "OR" (shown in the XPATH above).
> 
> The dumb answer: because that's how it's coded
> 
> The probable answer: you found a bug.
> 
> What to do:
>   1) file a bug report on bugzilla
>   2) write a test (code in java/test directory)
>   3) submit the patch to fix the problem
> 
> -Vladimir
> 
> 
> 
> 
> =====
> Vladimir R. Bossicard
> Apache Xindice - http://xml.apache.org/xindice
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> 






-------------------------------------------------
This mail sent through IMP: webmail.brad.ac.uk

Re: XPath problem

Posted by "Vladimir R. Bossicard" <vb...@yahoo.com>.
> Can anyone please tell me why this record is being returned twice when I
> use the boolean operator "OR" (shown in the XPATH above).

The dumb answer: because that's how it's coded

The probable answer: you found a bug.

What to do:
  1) file a bug report on bugzilla
  2) write a test (code in java/test directory)
  3) submit the patch to fix the problem

-Vladimir




=====
Vladimir R. Bossicard
Apache Xindice - http://xml.apache.org/xindice

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com