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 Vadim Gritsenko <va...@reverycodes.com> on 2004/02/19 03:49:36 UTC

Re: cocoon and xpath query

lilia ighmouracene wrote:

> hello,
>
> 1) i try to perform this xindice query within cocoon:
>
> http://localhost:8080/cocoon/db/PROTO/Medical/medical.xml?xpath=//*[@id='pfranck' 
> <http://64.4.30.250/cgi-bin/linkrd?_lang=FR&lah=c854706ed7856be8a74db95196822cf2&lat=1077123587&hm___action=http%3a%2f%2flocalhost%3a8080%2fcocoon%2fdb%2fPROTO%2fMedical%2fmedical%2exml%3fxpath%3d%2f%2f%2a%5b%40id%3d%27pfranck%27>]
> but i have the follow message error
>  
> "Référence à un préfixe d'espace de noms non déclaré  "
>  
> i have the response to the query but not wellformed because the prefix 
> xmldb which is used by xindice in the response is not declared as a 
> name space.
>  
> what i must do to resolve this problem,


Does this query work from command line? It might be Cocoon related 
problem, not Xindice.


> 2) a nother problem, when i perform this query in xindice  //@* , i 
> havent a response why


Xindice XML-RPC driver currently does not support attribute results. See 
test cases ("build test-integration-xmlrpc test-report", see 
build/test-report/)

Vadim


RE: XPath doesn't work

Posted by Jim Fuller <ji...@ruminate.co.uk>.
> XPath query don't work:
>    //div="first"

This is not valid xpath, this type of test should always be put in a
predicate, e.g. square brackets as your next example shows;

>    //div[@name="second"]
> 
> XPath query work:
>    //div="1"
>    //div[@name="2"]
> 
> What's the problem. I am using version1.0

I would suggest that you upgrade your version of xindice firstly, as no
one including the prolific Vadim supports it, and there are still some
rather big bugs with it.

gl, Jim Fuller


XPath doesn't work

Posted by Eric Zhang <yu...@ualberta.ca>.
In my experiment, XPath query doens't work on the character value of
attribute/element, but works on integer value of attribute/element.

My simple doc:

<book>
<div>first</first>
<div>1</div>
<div name="second"/>
<div name="2"/>
</book>

XPath query don't work:
   //div="first"
   //div[@name="second"]

XPath query work:
   //div="1"
   //div[@name="2"]

What's the problem. I am using version1.0

On Wed, 2004-02-18 at 19:49, Vadim Gritsenko wrote:
> lilia ighmouracene wrote:
> 
> > hello,
> >
> > 1) i try to perform this xindice query within cocoon:
> >
> > http://localhost:8080/cocoon/db/PROTO/Medical/medical.xml?xpath=//*[@id='pfranck' 
> > <http://64.4.30.250/cgi-bin/linkrd?_lang=FR&lah=c854706ed7856be8a74db95196822cf2&lat=1077123587&hm___action=http%3a%2f%2flocalhost%3a8080%2fcocoon%2fdb%2fPROTO%2fMedical%2fmedical%2exml%3fxpath%3d%2f%2f%2a%5b%40id%3d%27pfranck%27>]
> > but i have the follow message error
> >  
> > "Référence à un préfixe d'espace de noms non déclaré  "
> >  
> > i have the response to the query but not wellformed because the prefix 
> > xmldb which is used by xindice in the response is not declared as a 
> > name space.
> >  
> > what i must do to resolve this problem,
> 
> 
> Does this query work from command line? It might be Cocoon related 
> problem, not Xindice.
> 
> 
> > 2) a nother problem, when i perform this query in xindice  //@* , i 
> > havent a response why
> 
> 
> Xindice XML-RPC driver currently does not support attribute results. See 
> test cases ("build test-integration-xmlrpc test-report", see 
> build/test-report/)
> 
> Vadim
-- 
Yue(Eric) Zhang
Database Analyst/DBA, TAPoR Project
Arts Department, University of Alberta
Edmonton, AB, Canada


Re: Java Application Vs. Commandline Tool

Posted by Dan Alford <da...@appraisalforum.com>.
Eric,
Please check out

http://wiki.apache.org/xindice/XindiceFAQ/AttributeValue

The basic problem is you have to enclose the whole xpath in double 
quotes and single quote any values when running from the windows command 
line.

So change your command line query to: "//chapter[@name='eric']"

Regards,
Dan
Eric Zhang wrote:

>XPath query on the string value of element/attribute works in java
>application connected to the xindice, but not from command line
>
>XML
><book>
><chapter name="eric"/>
><chapter>test</chapter>
></book>
>
>XPath Query
>//chapter[@name="eric"]
>
>Works from a java app, but failed to find the doc from xindice's command
>line tool.
>
>
>  
>

Java Application Vs. Commandline Tool

Posted by Eric Zhang <yu...@ualberta.ca>.
XPath query on the string value of element/attribute works in java
application connected to the xindice, but not from command line

XML
<book>
<chapter name="eric"/>
<chapter>test</chapter>
</book>

XPath Query
//chapter[@name="eric"]

Works from a java app, but failed to find the doc from xindice's command
line tool.


-- 
Yue(Eric) Zhang
Database Analyst/DBA, TAPoR Project
Arts Department, University of Alberta
Edmonton, AB, Canada


Re: Load Big File?

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Eric Zhang wrote:

>Hi:
>  Is there anybody being able to load a big XML file to the database. I
>know Xindice is not designed to do that, however, the limitation of a
>string will easily be reached. I have a 11M xml file, when I try to load
>it using the example from xindice's site(the one read the content of a
>file to a string), it gives me an out of memory mistake.
>  
>

Increase the memory. Add parameters to the java:
-Xms128m -Xmx256m

and try again.


>  I then tried to use create a DOM/other create resource way and load
>it, which give me an error: XML:DB Exception occured 0
>  
>

Add -v parameter to see exception message / stack trace.

Vadim


Load Big File?

Posted by Eric Zhang <yu...@ualberta.ca>.
Hi:
  Is there anybody being able to load a big XML file to the database. I
know Xindice is not designed to do that, however, the limitation of a
string will easily be reached. I have a 11M xml file, when I try to load
it using the example from xindice's site(the one read the content of a
file to a string), it gives me an out of memory mistake.
  I then tried to use create a DOM/other create resource way and load
it, which give me an error: XML:DB Exception occured 0

  The script I used :
	Test1:

        File file = new File("test.xml");
        byte[] temp1 = getBytesFromFile(file);
        DocumentImpl aNode = new DocumentImpl(temp1);
        XMLResource document = new
	XMLResourceImpl("hehe",col,null,temp1) ;
        col.storeResource(document);

	Test2:
	DocumentImpl aDOM = new DocumentImpl();
        aDOM.createElement("hehehehe");
        XMLResource document =
(XMLResource)col.createResource("hehe","XMLResource");
        document.setContentAsDOM(aDOM);
        col.storeResource(document);

Any idea?

-- 
Yue(Eric) Zhang
Database Analyst/DBA, TAPoR Project
Arts Department, University of Alberta
Edmonton, AB, Canada


Re: Performance with index?

Posted by Terry Rosenbaum <Te...@amicas.com>.
Using contains or ends-with in you query will
ensure that a scan over the whole collection will
occur. Indexing will never be used to evaulate
the contains or ends-with functions in Xindice
as currently implemented.

A value index, if present on the proper attribute or element,
will be used to evaluate equality and starts-with.

To evaluate contains and ends-with efficiently using indexing would
require a different kind of index that Xindice does not currently
support (e.g. substring for either contains or ends-with, or
reversed value index for ends-with). (Maybe there would be
some gain by performing contains or ends-with by scanning the entire
index during the index evaluation phase, but that is not implemented).

Indexes are used to try to narrow the set of resources
that could possibly match the query to less than the entire collection.

Once the indexed partial evaluation has been completed,
a standard XPath evaluation is run on each resource in
the (hopefully) narrowed set to produce the final answer.
Thus, you can see that if the use of indexes fails to
significantly narrow the query, it would have been
faster to just run an XPath evaluation against each
of the resources in the collection and skip the index
evaluation entirely.

-Terry

Jeff Greif wrote:

>Indexes in xindice worked as follows (at the time I last used it, over a
>year ago):
>1.  The index maps from element or attribute values to documents.  It tells
>you which documents in a collection contain the value in question.
>2.  As such, if properly implemented, it could also be used to partially
>optimize queries testing "contains", "starts_with" and "ends_with" for the
>indexed elements or attributes.
>3.  Once the index determines which documents to examine, each document must
>be subject to extraction via the xpath of the query.  This means the entire
>document must be scanned if the xpath starts with //, and large subtrees
>must be scanned if the path contains // elsewhere than at the beginning.
>4.  Clearly the index will work best when the documents are small and not be
>useful when there is just one document.
>
>I believe this information should help answer your questions.
>
>Jeff
>----- Original Message ----- 
>From: "Eric Zhang" <yu...@ualberta.ca>
>To: <xi...@xml.apache.org>
>Sent: Saturday, February 21, 2004 10:01 AM
>Subject: Performance with index?
>
>
>  
>
>>Hi all:
>>  I have some question about using index on xindice. I have a fairly large
>>    
>>
>xml
>  
>
>>file(2.3M), with lots of nosense element, however, there are only two
>>    
>>
>element I
>  
>
>>interested in the file:  <div>test</div> <div name="algo"/>
>>
>>I want to query this xml file using xpath //div[.="test"],
>>    
>>
>//div[@name="algo"],
>  
>
>>and //div to get the element I want. The processing time is pretty long.
>>    
>>
>However,
>  
>
>>after I add indexes
>>xindice ai -c /db/test -p div
>>xindice ai -c /db/test -p div@name
>>their performance doesn't get any better.
>>
>>My questions are:
>>- Whether the index of Xindice only helps the query on lots of files,
>>  not on a sinlge file?
>>- If the index can work on a single file, whether the way I am creating
>>  the index is right?
>>- In one word, how can I create a index on a document to help me
>>  quickly find the element I want with its value or its attribute's value
>>  as search keyword?
>>
>>Thanks a lot
>>
>>    
>>
>>>Yue(Eric) Zhang
>>>Database Analyst/DBA, TAPoR Project
>>>Arts Department, University of Alberta
>>>Edmonton, AB, Canada
>>>      
>>>
>>    
>>
>
>  
>

Re: Performance with index?

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
Indexes in xindice worked as follows (at the time I last used it, over a
year ago):
1.  The index maps from element or attribute values to documents.  It tells
you which documents in a collection contain the value in question.
2.  As such, if properly implemented, it could also be used to partially
optimize queries testing "contains", "starts_with" and "ends_with" for the
indexed elements or attributes.
3.  Once the index determines which documents to examine, each document must
be subject to extraction via the xpath of the query.  This means the entire
document must be scanned if the xpath starts with //, and large subtrees
must be scanned if the path contains // elsewhere than at the beginning.
4.  Clearly the index will work best when the documents are small and not be
useful when there is just one document.

I believe this information should help answer your questions.

Jeff
----- Original Message ----- 
From: "Eric Zhang" <yu...@ualberta.ca>
To: <xi...@xml.apache.org>
Sent: Saturday, February 21, 2004 10:01 AM
Subject: Performance with index?


> Hi all:
>   I have some question about using index on xindice. I have a fairly large
xml
> file(2.3M), with lots of nosense element, however, there are only two
element I
> interested in the file:  <div>test</div> <div name="algo"/>
>
> I want to query this xml file using xpath //div[.="test"],
//div[@name="algo"],
> and //div to get the element I want. The processing time is pretty long.
However,
> after I add indexes
> xindice ai -c /db/test -p div
> xindice ai -c /db/test -p div@name
> their performance doesn't get any better.
>
> My questions are:
> - Whether the index of Xindice only helps the query on lots of files,
>   not on a sinlge file?
> - If the index can work on a single file, whether the way I am creating
>   the index is right?
> - In one word, how can I create a index on a document to help me
>   quickly find the element I want with its value or its attribute's value
>   as search keyword?
>
> Thanks a lot
>
> >
> > Yue(Eric) Zhang
> > Database Analyst/DBA, TAPoR Project
> > Arts Department, University of Alberta
> > Edmonton, AB, Canada
>
>


Performance with index?

Posted by Eric Zhang <yu...@ualberta.ca>.
Hi all:
  I have some question about using index on xindice. I have a fairly large xml
file(2.3M), with lots of nosense element, however, there are only two element I
interested in the file:  <div>test</div> <div name="algo"/>

I want to query this xml file using xpath //div[.="test"], //div[@name="algo"],
and //div to get the element I want. The processing time is pretty long. However,
after I add indexes
	xindice ai -c /db/test -p div
	xindice ai -c /db/test -p div@name
their performance doesn't get any better.

My questions are:
	- Whether the index of Xindice only helps the query on lots of files, 
	  not on a sinlge file?
	- If the index can work on a single file, whether the way I am creating
	  the index is right?
	- In one word, how can I create a index on a document to help me 
	  quickly find the element I want with its value or its attribute's value
	  as search keyword?

Thanks a lot

>  
> Yue(Eric) Zhang
> Database Analyst/DBA, TAPoR Project
> Arts Department, University of Alberta
> Edmonton, AB, Canada


Re: Commandline failed

Posted by Honglin Ye <hy...@aoc.nrao.edu>.
Eric Zhang wrote:

> Hi all:
>   I just complied and installed xindice 1.3b. And the tomcat runs well and I am 
> already able to browse the database from http://localhost/8080/xindice
> however, when I run command line tools, i got following error:
> 
>  I run: xindice list_collections -c /db/data
> 
> [DEBUG] DatabaseImpl - -Using SAX Driver: 'xerces'
> [DEBUG] DatabaseImpl - -Using Service Location: '/xindice/'
> [DEBUG] CollectionImpl - -Using URL: 'http://127.0.0.1:8888/xindice/'
> XMLDB Exception with code 0
> 
> Any help? Thanks.
> 
> 
> 
try this

xindice lc -c xmldb:xindice://localhost:8080/db/data


Honglin Ye


Commandline failed

Posted by Eric Zhang <yu...@ualberta.ca>.
Hi all:
  I just complied and installed xindice 1.3b. And the tomcat runs well and I am 
already able to browse the database from http://localhost/8080/xindice
however, when I run command line tools, i got following error:

 I run: xindice list_collections -c /db/data

[DEBUG] DatabaseImpl - -Using SAX Driver: 'xerces'
[DEBUG] DatabaseImpl - -Using Service Location: '/xindice/'
[DEBUG] CollectionImpl - -Using URL: 'http://127.0.0.1:8888/xindice/'
XMLDB Exception with code 0

Any help? Thanks.