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 Larry White <lj...@earthlink.net> on 2001/12/19 22:30:33 UTC

Xpath query question

I'm working with dbxml (v1.0b4) with good results creating collections,
reading and writing docs, etc., except that I can't get any results from
xpath queries.  I was working with the java api without results and
switched to the command line utilities to try to isolate the problem.

Based on an example in the documentation, I ran the following query:
>>dbxml xpath_query -c /db/ip/system/users -q /USER[@username="admin"]

It ran without producing any output.

Listing the documents in the /db/ip/system/users collection shows that a
document called default_admin exits in the collection:

    >dbxmladmin ld -c /db/ip/system/users
            default_admin
    Total documents: 1

I printed the document's contents and produced  the following results:
(with some USER sub-nodes removed for brevity).

<?xml version="1.0"?>
<?xml-stylesheet href="user_edit.xsl" type="text/xsl"?>
<USER username="admin" password="admin" status="active">
    <PERSON_NAME>
    </PERSON_NAME>
    <PHONE_NUMBERS>
        <PHONE_NUMBER>
        </PHONE_NUMBER>
    </PHONE_NUMBERS>
    <EMAIL_ADDRESS />
</USER>

Shouldn't the USER node be returned, as it has the attribute
password="admin"?


-------
Lawrence White
Email: ljw1001@earthlink.net



Re: Xpath query question

Posted by se...@web.de.
Hmm, i'm just looking at my code and it's the same as yours. and it works.
My config: win2k, tomcat4 and dbxml b4 (worked also with b2). i always used
standard installation (xalan, xerces and so on)
and your're right: i tried the same query with " and it worked as well.
can you query the /USER without specifing the username attr to control what
exactly is stored in db. perhaps the insertion failed. only a guess....i
think have checked this before...

seb
----- Original Message -----
From: "Larry White" <lj...@earthlink.net>
To: <xi...@xml.apache.org>
Sent: Thursday, December 20, 2001 12:33 AM
Subject: Re: Xpath query question


> Afraid it's not that simple :(.
>
> I get no results working through command line or the API.  Here's the java
code
> I used: as well as the output.  I'm starting to think it may be a
versioning
> problem with one of the libraries I'm using. Possibly Xalan, though I
think I'm
> on the latest version.  Any suggestions are appreciated.
>
> public static ResourceSet invokeQuery(String xpath, String collectionPath)
{
>         Collection col = null;
>         ResourceSet results = null;
>         cat.debug("XPath: " + xpath);
>         cat.debug("Collection Path " + collectionPath);
>         try {
>             String driver = "org.dbxml.client.xmldb.DatabaseImpl";
>             Class c = Class.forName(driver);
>
>             Database database = (Database) c.newInstance();
>             DatabaseManager.registerDatabase(database);
>             col =
> DatabaseManager.getCollection("xmldb:dbxml:///db/"+collectionPath);
>             XPathQueryService service =  (XPathQueryService)
> col.getService("XPathQueryService", "1.0");
>             results = service.query(xpath);
>             if (results.getSize() == 0) { cat.debug("No results were
> returned");}
>
>         } catch .... etc.
>
> Results:
> 10641 [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - XPath:
> /USER[@username='admin']
> 10656 [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  -
Collection
> Path ip/system/users
> 11203 [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - No
results
> were returned
>
>
>
>
>
> sebssmoller@web.de wrote:
>
> > hi,
> > it's exactly like Tom said. I also use Windows 2000 and i use single
quotes
> > and everything works fine. from commandline and from Java API.
> >
> > Regards
> > Seb
> >
> > ----- Original Message -----
> > From: "Tom Bradford" <br...@dbxmlgroup.com>
> > To: <xi...@xml.apache.org>
> > Sent: Wednesday, December 19, 2001 11:44 PM
> > Subject: Re: Xpath query question
> >
> > > Larry White wrote:
> > > > yes windows nt 4.0
> > >
> > > There are issues with command line quoting in Windows.  I'm not sure
> > > what the correct workaround would be, but typically issuing your query
> > > like this should do the job:
> > >
> > > dbxml xpath-query -c /db/ip/system/users -q "/USER[@username='admin']"
> > >
> > > If that doesn't work, I'm sure some of the Windows users on the list
> > > would be happy to help out.  I don't use Windows, so I can't
> > > authoritatively say that it will work.  If you use the XML:DB API to
> > > perform the query, you'll never run into problems like these.
> > >
> > > --
> > > Tom Bradford - http://www.tbradford.org
> > > Developer - Apache Xindice (formerly dbXML)
> > > Maintainer - jEdit-Syntax Java Editing Bean
>
> --
> -------
> Lawrence White
> Telephone: 508.843.3128
> Email: ljw1001@earthlink.net
>
>


Re: Xpath query question

Posted by Murray Altheim <mu...@sun.com>.
Larry White wrote:
> 
> I found the the problem:
> 
> I had upgraded to the latest version of Xalan, the one that ships with the -
> Sun Fall 2001 Java XML Pack to work around a problem with SAX filters.
> Changing back to the Xalan-2.0.1 version that ships with dbxml 1.0.b4 fixed
> the problem.
> 
> Thanks for your help.

Our group here is doing a project that includes Xindice, and in our testing
we've noted problems between Java 1.3 and 1.4 stemming from the latter's
inclusion of XML support from Apache (not to blame Apache, but all code
has bugs so it's really just a matter of who is responsible and how fast
they fix them). We're pressuring the team responsible for Xerces 2 to fix
bugs that we know are causing problems for us with Xindice and they've been
fairly responsive, if that's any reassurance. I talked with their project 
manager yesterday and he seemed pretty cool about lighting the fires under
the programmer's butts.

In the interim we may all have to futz with jar files to be sure things
work correctly. I don't think it'll be too long, though it does rely to
some extent on release schedules.

Murray

...........................................................................
Murray Altheim                         <mailto:murray.altheim&#x40;sun.com>
XML Technology Center, Java and XML Software
Sun Microsystems, Inc., MS MPK17-102, 1601 Willow Rd., Menlo Park, CA 94025

               Rally against the evils of iceburg lettuce! 
            Grab a kitchen knife and join the Balsamic Jihad!

Re: Xpath query question

Posted by Larry White <lj...@earthlink.net>.
I found the the problem:

I had upgraded to the latest version of Xalan, the one that ships with the -
Sun Fall 2001 Java XML Pack to work around a problem with SAX filters.
Changing back to the Xalan-2.0.1 version that ships with dbxml 1.0.b4 fixed
the problem.

Thanks for your help.

-- larry

"Timothy M. Dean" wrote:

> I was having a similar problem when I first started using Xindice. One
> thing I found that you might want to check. I have an installed version
> of JDK 1.4 on my machine. My JDK home variables were set to JDK 1.3.1,
> but there was a 1.4 "java" executable on my path (in the Windows system
> directory).
>
> I don't know what support for 1.4 we should expect with Xindice: I might
> have had a mixed system where server was running with one JDK while the
> command line was running another. In either case, once I removed the 1.4
> "java.exe" from my Windows system disk, everything worked better.
>
> Just a thought - Hope it helps.
>
> - Tim
>
> -----Original Message-----
> From: Larry White [mailto:ljw1001@earthlink.net]
> Sent: Wednesday, December 19, 2001 5:33 PM
> To: xindice-users@xml.apache.org
> Subject: Re: Xpath query question
>
> Afraid it's not that simple :(.
>
> I get no results working through command line or the API.  Here's the
> java code I used: as well as the output.  I'm starting to think it may
> be a versioning problem with one of the libraries I'm using. Possibly
> Xalan, though I think I'm on the latest version.  Any suggestions are
> appreciated.
>
> public static ResourceSet invokeQuery(String xpath, String
> collectionPath)  {
>         Collection col = null;
>         ResourceSet results = null;
>         cat.debug("XPath: " + xpath);
>         cat.debug("Collection Path " + collectionPath);
>         try {
>             String driver = "org.dbxml.client.xmldb.DatabaseImpl";
>             Class c = Class.forName(driver);
>
>             Database database = (Database) c.newInstance();
>             DatabaseManager.registerDatabase(database);
>             col =
> DatabaseManager.getCollection("xmldb:dbxml:///db/"+collectionPath);
>             XPathQueryService service =  (XPathQueryService)
> col.getService("XPathQueryService", "1.0");
>             results = service.query(xpath);
>             if (results.getSize() == 0) { cat.debug("No results were
> returned");}
>
>         } catch .... etc.
>
> Results:
> 10641 [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - XPath:
> /USER[@username='admin'] 10656 [HttpProcessor[8080][4]] DEBUG
> project.dbxml.XMLDatabase  - Collection Path ip/system/users 11203
> [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - No results
> were returned
>
> sebssmoller@web.de wrote:
>
> > hi,
> > it's exactly like Tom said. I also use Windows 2000 and i use single
> > quotes and everything works fine. from commandline and from Java API.
> >
> > Regards
> > Seb
> >
> > ----- Original Message -----
> > From: "Tom Bradford" <br...@dbxmlgroup.com>
> > To: <xi...@xml.apache.org>
> > Sent: Wednesday, December 19, 2001 11:44 PM
> > Subject: Re: Xpath query question
> >
> > > Larry White wrote:
> > > > yes windows nt 4.0
> > >
> > > There are issues with command line quoting in Windows.  I'm not sure
>
> > > what the correct workaround would be, but typically issuing your
> > > query like this should do the job:
> > >
> > > dbxml xpath-query -c /db/ip/system/users -q
> > > "/USER[@username='admin']"
> > >
> > > If that doesn't work, I'm sure some of the Windows users on the list
>
> > > would be happy to help out.  I don't use Windows, so I can't
> > > authoritatively say that it will work.  If you use the XML:DB API to
>
> > > perform the query, you'll never run into problems like these.
> > >
> > > --
> > > Tom Bradford - http://www.tbradford.org
> > > Developer - Apache Xindice (formerly dbXML)
> > > Maintainer - jEdit-Syntax Java Editing Bean
>
> --
> -------
> Lawrence White
> Telephone: 508.843.3128
> Email: ljw1001@earthlink.net

--
-------
Lawrence White
Telephone: 508.843.3128
Email: ljw1001@earthlink.net



RE: Xpath query question

Posted by "Timothy M. Dean" <td...@visi.com>.
I was having a similar problem when I first started using Xindice. One
thing I found that you might want to check. I have an installed version
of JDK 1.4 on my machine. My JDK home variables were set to JDK 1.3.1,
but there was a 1.4 "java" executable on my path (in the Windows system
directory).

I don't know what support for 1.4 we should expect with Xindice: I might
have had a mixed system where server was running with one JDK while the
command line was running another. In either case, once I removed the 1.4
"java.exe" from my Windows system disk, everything worked better.

Just a thought - Hope it helps.

- Tim


-----Original Message-----
From: Larry White [mailto:ljw1001@earthlink.net] 
Sent: Wednesday, December 19, 2001 5:33 PM
To: xindice-users@xml.apache.org
Subject: Re: Xpath query question


Afraid it's not that simple :(.

I get no results working through command line or the API.  Here's the
java code I used: as well as the output.  I'm starting to think it may
be a versioning problem with one of the libraries I'm using. Possibly
Xalan, though I think I'm on the latest version.  Any suggestions are
appreciated.

public static ResourceSet invokeQuery(String xpath, String
collectionPath)  {
        Collection col = null;
        ResourceSet results = null;
        cat.debug("XPath: " + xpath);
        cat.debug("Collection Path " + collectionPath);
        try {
            String driver = "org.dbxml.client.xmldb.DatabaseImpl";
            Class c = Class.forName(driver);

            Database database = (Database) c.newInstance();
            DatabaseManager.registerDatabase(database);
            col =
DatabaseManager.getCollection("xmldb:dbxml:///db/"+collectionPath);
            XPathQueryService service =  (XPathQueryService)
col.getService("XPathQueryService", "1.0");
            results = service.query(xpath);
            if (results.getSize() == 0) { cat.debug("No results were
returned");}

        } catch .... etc.

Results:
10641 [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - XPath:
/USER[@username='admin'] 10656 [HttpProcessor[8080][4]] DEBUG
project.dbxml.XMLDatabase  - Collection Path ip/system/users 11203
[HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - No results
were returned





sebssmoller@web.de wrote:

> hi,
> it's exactly like Tom said. I also use Windows 2000 and i use single 
> quotes and everything works fine. from commandline and from Java API.
>
> Regards
> Seb
>
> ----- Original Message -----
> From: "Tom Bradford" <br...@dbxmlgroup.com>
> To: <xi...@xml.apache.org>
> Sent: Wednesday, December 19, 2001 11:44 PM
> Subject: Re: Xpath query question
>
> > Larry White wrote:
> > > yes windows nt 4.0
> >
> > There are issues with command line quoting in Windows.  I'm not sure

> > what the correct workaround would be, but typically issuing your 
> > query like this should do the job:
> >
> > dbxml xpath-query -c /db/ip/system/users -q 
> > "/USER[@username='admin']"
> >
> > If that doesn't work, I'm sure some of the Windows users on the list

> > would be happy to help out.  I don't use Windows, so I can't 
> > authoritatively say that it will work.  If you use the XML:DB API to

> > perform the query, you'll never run into problems like these.
> >
> > --
> > Tom Bradford - http://www.tbradford.org
> > Developer - Apache Xindice (formerly dbXML)
> > Maintainer - jEdit-Syntax Java Editing Bean

--
-------
Lawrence White
Telephone: 508.843.3128
Email: ljw1001@earthlink.net





Re: Xpath query question

Posted by Larry White <lj...@earthlink.net>.
Afraid it's not that simple :(.

I get no results working through command line or the API.  Here's the java code
I used: as well as the output.  I'm starting to think it may be a versioning
problem with one of the libraries I'm using. Possibly Xalan, though I think I'm
on the latest version.  Any suggestions are appreciated.

public static ResourceSet invokeQuery(String xpath, String collectionPath)  {
        Collection col = null;
        ResourceSet results = null;
        cat.debug("XPath: " + xpath);
        cat.debug("Collection Path " + collectionPath);
        try {
            String driver = "org.dbxml.client.xmldb.DatabaseImpl";
            Class c = Class.forName(driver);

            Database database = (Database) c.newInstance();
            DatabaseManager.registerDatabase(database);
            col =
DatabaseManager.getCollection("xmldb:dbxml:///db/"+collectionPath);
            XPathQueryService service =  (XPathQueryService)
col.getService("XPathQueryService", "1.0");
            results = service.query(xpath);
            if (results.getSize() == 0) { cat.debug("No results were
returned");}

        } catch .... etc.

Results:
10641 [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - XPath:
/USER[@username='admin']
10656 [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - Collection
Path ip/system/users
11203 [HttpProcessor[8080][4]] DEBUG project.dbxml.XMLDatabase  - No results
were returned





sebssmoller@web.de wrote:

> hi,
> it's exactly like Tom said. I also use Windows 2000 and i use single quotes
> and everything works fine. from commandline and from Java API.
>
> Regards
> Seb
>
> ----- Original Message -----
> From: "Tom Bradford" <br...@dbxmlgroup.com>
> To: <xi...@xml.apache.org>
> Sent: Wednesday, December 19, 2001 11:44 PM
> Subject: Re: Xpath query question
>
> > Larry White wrote:
> > > yes windows nt 4.0
> >
> > There are issues with command line quoting in Windows.  I'm not sure
> > what the correct workaround would be, but typically issuing your query
> > like this should do the job:
> >
> > dbxml xpath-query -c /db/ip/system/users -q "/USER[@username='admin']"
> >
> > If that doesn't work, I'm sure some of the Windows users on the list
> > would be happy to help out.  I don't use Windows, so I can't
> > authoritatively say that it will work.  If you use the XML:DB API to
> > perform the query, you'll never run into problems like these.
> >
> > --
> > Tom Bradford - http://www.tbradford.org
> > Developer - Apache Xindice (formerly dbXML)
> > Maintainer - jEdit-Syntax Java Editing Bean

--
-------
Lawrence White
Telephone: 508.843.3128
Email: ljw1001@earthlink.net



Re: Xpath query question

Posted by se...@web.de.
hi,
it's exactly like Tom said. I also use Windows 2000 and i use single quotes
and everything works fine. from commandline and from Java API.

Regards
Seb

----- Original Message -----
From: "Tom Bradford" <br...@dbxmlgroup.com>
To: <xi...@xml.apache.org>
Sent: Wednesday, December 19, 2001 11:44 PM
Subject: Re: Xpath query question


> Larry White wrote:
> > yes windows nt 4.0
>
> There are issues with command line quoting in Windows.  I'm not sure
> what the correct workaround would be, but typically issuing your query
> like this should do the job:
>
> dbxml xpath-query -c /db/ip/system/users -q "/USER[@username='admin']"
>
> If that doesn't work, I'm sure some of the Windows users on the list
> would be happy to help out.  I don't use Windows, so I can't
> authoritatively say that it will work.  If you use the XML:DB API to
> perform the query, you'll never run into problems like these.
>
> --
> Tom Bradford - http://www.tbradford.org
> Developer - Apache Xindice (formerly dbXML)
> Maintainer - jEdit-Syntax Java Editing Bean


Re: Xpath query question

Posted by Tom Bradford <br...@dbxmlgroup.com>.
Larry White wrote:
> yes windows nt 4.0

There are issues with command line quoting in Windows.  I'm not sure
what the correct workaround would be, but typically issuing your query
like this should do the job:

dbxml xpath-query -c /db/ip/system/users -q "/USER[@username='admin']"

If that doesn't work, I'm sure some of the Windows users on the list
would be happy to help out.  I don't use Windows, so I can't
authoritatively say that it will work.  If you use the XML:DB API to
perform the query, you'll never run into problems like these.

-- 
Tom Bradford - http://www.tbradford.org
Developer - Apache Xindice (formerly dbXML)
Maintainer - jEdit-Syntax Java Editing Bean

Re: Xpath query question

Posted by Larry White <lj...@earthlink.net>.
yes windows nt 4.0


Tom Bradford wrote:

> Larry White wrote:
> > I'm working with dbxml (v1.0b4) with good results creating collections,
> > reading and writing docs, etc., except that I can't get any results from
> > xpath queries.  I was working with the java api without results and
> > switched to the command line utilities to try to isolate the problem.
> >
> > Based on an example in the documentation, I ran the following query:
> > >>dbxml xpath_query -c /db/ip/system/users -q /USER[@username="admin"]
> >
> > It ran without producing any output.
>
> Are you using Windows? :-)
>
> --
> Tom Bradford - http://www.tbradford.org
> Developer - Apache Xindice (formerly dbXML)
> Maintainer - jEdit-Syntax Java Editing Bean

--
-------
Lawrence White
Telephone: 508.843.3128
Email: ljw1001@earthlink.net



Re: Xpath query question

Posted by Tom Bradford <br...@dbxmlgroup.com>.
Larry White wrote:
> I'm working with dbxml (v1.0b4) with good results creating collections,
> reading and writing docs, etc., except that I can't get any results from
> xpath queries.  I was working with the java api without results and
> switched to the command line utilities to try to isolate the problem.
> 
> Based on an example in the documentation, I ran the following query:
> >>dbxml xpath_query -c /db/ip/system/users -q /USER[@username="admin"]
> 
> It ran without producing any output.

Are you using Windows? :-)

-- 
Tom Bradford - http://www.tbradford.org
Developer - Apache Xindice (formerly dbXML)
Maintainer - jEdit-Syntax Java Editing Bean

RE: Xpath query question

Posted by "Timothy M. Dean" <td...@visi.com>.
I have a similar problem when I use the command line, but only when I
filter by an attribute as you have done. If, for example, you take off
the [@username="admin"] from your quiry, do you get a list of all USER
nodes? In my case I do...

Note that this only occurs for me when I use the command line. When I
implement the query programatically it works just fine for me.

I am using Windows 2000 SP1 at the current time.

- Tim


> -----Original Message-----
> From: Larry White [mailto:ljw1001@earthlink.net] 
> Sent: Wednesday, December 19, 2001 3:31 PM
> To: users xindice
> Subject: Xpath query question
> 
> 
> I'm working with dbxml (v1.0b4) with good results creating 
> collections, reading and writing docs, etc., except that I 
> can't get any results from xpath queries.  I was working with 
> the java api without results and switched to the command line 
> utilities to try to isolate the problem.
> 
> Based on an example in the documentation, I ran the following query:
> >>dbxml xpath_query -c /db/ip/system/users -q /USER[@username="admin"]
> 
> It ran without producing any output.
> 
> Listing the documents in the /db/ip/system/users collection 
> shows that a document called default_admin exits in the collection:
> 
>     >dbxmladmin ld -c /db/ip/system/users
>             default_admin
>     Total documents: 1
> 
> I printed the document's contents and produced  the following 
> results: (with some USER sub-nodes removed for brevity).
> 
> <?xml version="1.0"?>
> <?xml-stylesheet href="user_edit.xsl" type="text/xsl"?>
> <USER username="admin" password="admin" status="active">
>     <PERSON_NAME>
>     </PERSON_NAME>
>     <PHONE_NUMBERS>
>         <PHONE_NUMBER>
>         </PHONE_NUMBER>
>     </PHONE_NUMBERS>
>     <EMAIL_ADDRESS />
> </USER>
> 
> Shouldn't the USER node be returned, as it has the attribute 
> password="admin"?
> 
> 
> -------
> Lawrence White
> Email: ljw1001@earthlink.net
> 
> 
> 


Re: Xpath query question

Posted by Dave Pawson <da...@dpawson.freeserve.co.uk>.
At 16:30 19/12/2001 -0500, Larry White wrote:
>I'm working with dbxml (v1.0b4) with good results creating collections,
>reading and writing docs, etc., except that I can't get any results from
>xpath queries.  I was working with the java api without results

Been there, done that.
Tweak Example1.java to encompass the query you want,
it prints out content (to the command line) as you might
expect the command line to do.
Don't forget to remove the package spec in that program!

HTH DaveP