Dear Ankur, try :
for $book in /bookstore/book
where $book/author = ‘ABC’
order by $book/title
return
$book
There are many XQuery tutorials available on the web,
http://www.w3schools.com/xquery/default.asp
for example, if you like the bookstore use case !
Be careful with BaseX, you may become addicted to XQuery ;-)
Regards,
Fabrice
De : basex-talk-bounces@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de]
De la part de Ankur Kasliwal
Envoyé : lundi 21 janvier 2013 17:19
Ŕ : Christian Grün
Cc : BaseX
Objet : Re: [basex-talk] Use of BaseX
I did some work and try to avoid using the RDBMS part. So here is my question again
If I have 100 XML files with structure as :
<bookstore>
<book>
<title>Learn XML</title>
<author>ABC</author>
</book>
<book>
<title>Learn Java</title>
<author>PQR</author>
</book>
-------
------- { more such book elements}
</bookstore>
So if I want to directly write query like " All books authored by "ABC" sorted by name of book" on the collection of 100 XML files. Is there anyway of doing this with Xquery/Xpath. Can someone provide me steps and a query for doing that.
Also one more question as BaseX is a database for XML but I am not actually able to figure out its real advantages over databases available. Is its interface or functionality or anything else which is better than other databases.
Thank you in advance and hope to hear from you soon.
--
Ankur
On Mon, Jan 21, 2013 at 4:43 AM, Christian Grün <christian.gruen@gmail.com> wrote:
> I have 10 of these files in my collection. So my question is how can I query
> all these Xml files at ones and get specific results like "Books with price
> value greater than 100".
Use a simple XPath expression [1], such as
collection("name-of-collection"//Books[Price > 100]
You mentioned our REST service, which can also be used for that [2]:
http://localhost:8984/rest/name-of-collection?query=//Books...
> Once I get these results I want to store the result
> in a RDBMS so that at later point I can query that RDBMS to generate certain
> reports.
Check out the SQL Module of our documentation [3] and give it a try.
Regards,
Christian
[1] http://www.w3schools.com/xpath/
[2] http://docs.basex.org/wiki/REST
[3] http://docs.basex.org/wiki/SQL
--
Sincerely,
Ankur Kasliwal
MS in CS, Northeastern University
(916)-673-7559