One question.
It seems that the results from xpath_query are retuned as a set of xml
results, is there a design reason why queries don't return an valid xml
document?
Something like this:
<resultSet>
<dish num="2" src:col="/db/food" src:key="food1.xml"
xmlns:src="http://xml.apache.org/xindice/Query">pho</dish>
<dish num="2" src:col="/db/food" src:key="food2.xml"
xmlns:src="http://xml.apache.org/xindice/Query">Omelet </dish>
<dish num="2" src:col="/db/food" src:key="food3.xml"
xmlns:src="http://xml.apache.org/xindice/Query">steak</dish>
<dish num="2" src:col="/db/food" src:key="food4.xml"
xmlns:src="http://xml.apache.org/xindice/Query">snickers</dish>
</resultSet>
It would be nice as one could then easily access the contents of the
document using DOM.
Thanks
Peter
-----Original Message-----
From: Vadim Gritsenko [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 03, 2004 6:24 PM
To: [email protected]
Subject: Re: Query Results
Peter Charles wrote:
>Hello,
>
>I have some questions about the query behavior
>
>I created a collection food and put the following documents into it.
>
><food type="snack">
> <dish num="1">apple</dish>
> <dish num="2">snickers</dish>
> <dish num="3">crackers</dish>
> <dish num="4">carrots</dish>
></food>
><food type="lunch">
> <dish num="1">spagetti</dish>
> <dish num="2">steak</dish>
> <dish num="3">macroni and cheese</dish>
> <dish num="4">stir fry</dish>
></food>
><food type="breakfast">
> <dish num="1">Toast</dish>
> <dish num="2">Omelet </dish>
> <dish num="3">Cereal</dish>
> <dish num="4">Bagel</dish>
></food>
><food type="lunch">
> <dish num="1">sandwich</dish>
> <dish num="2">pho</dish>
> <dish num="3">pizza</dish>
> <dish num="4">leftovers</dish>
></food>
>
>if I use the following query I get the expected result:
>
>xindice xpath_query -c /db/food -q"/[EMAIL PROTECTED]'snack']"
>trying to register database
>
><food src:col="/db/food" src:key="food4.xml" type="snack"
>xmlns:src="http://xml.apache.org/xindice/Query">
> <dish num="1">apple</dish>
> <dish num="2">snickers</dish>
> <dish num="3">crackers</dish>
> <dish num="4">carrots</dish>
></food>
>
>if I do the following query I get the expected results.
>
>C:\Documents and Settings\peter>xindice xpath_query -c /db/food -q
>"/food/[EMAIL PROTECTED]'2']"
>
>trying to register database
><dish num="2" src:col="/db/food" src:key="food1.xml"
>xmlns:src="http://xml.apache.org/xindice/Query">pho</dish>
><dish num="2" src:col="/db/food" src:key="food2.xml"
>xmlns:src="http://xml.apache.org/xindice/Query">Omelet </dish>
><dish num="2" src:col="/db/food" src:key="food3.xml"
>xmlns:src="http://xml.apache.org/xindice/Query">steak</dish>
><dish num="2" src:col="/db/food" src:key="food4.xml"
>xmlns:src="http://xml.apache.org/xindice/Query">snickers</dish>
>
>but if I do the following query:
>
>xindice xpath_query -c /db/food -q "/food/dish/.='pho'"
>
>trying to register database
><xq:result
>xmlns:xq="http://xml.apache.org/xindice/Query">true</xq:result>
><xq:result
>xmlns:xq="http://xml.apache.org/xindice/Query">false</xq:result>
><xq:result
>xmlns:xq="http://xml.apache.org/xindice/Query">false</xq:result>
><xq:result
>xmlns:xq="http://xml.apache.org/xindice/Query">false</xq:result>
>
>I get a result that tells me that there is a <dish>pho</dish> in my
>collection, but gives me no information about what document it is in,
>which seems strange.
>
>I understand the different nature of these XPath expressions, however
>the query seem a natural one, but the result is not particularly
useful.
>
>Is this just a limitation of the command line tool?
>
>I'm going to start working with the API now :)
>
>
I have a patch sitting on my drive fixing this issue, but I've not yet
committed yet... I'll fix this before monday. Somebody also needs to
write something up on the behavior of different xpath queries in the
xindice... Wiki page "XPathQuery" sounds like appropriate place... Any
takers? :-)
Vadim