Hi,i have created a database in BaseX GUI but i did not understand how to use it inside FLWR query.So since i would like to create one FLWR query to query all my files in the database not only one file with doc()i have tried collection() is that right? (i have putted all my xml files inside path/ directory)This is my query: let $d:=collection ("path/")
let $r:=doc("myfile1.xml")
for $d in$d// item/@qcode="tx"
where $d//subj[text() contains text { 'Hal', 'Fade' } any] and$r/subj ="Berlin
"return
<results>$d/tit</results>
it shows me error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false(). what is that error about?----Thank youBest regards
Hi,
you do not need to use doc() or collection() if your documents are stored in a database.
The documents are just nodes as well, so doing something like:
let $db := db:open('some-db') for $d in $db//item/@qcode="tx" return $d
would return the items from all nodes (all files)
BTW: I guess you want: $db// item[@qcode="tx"]
Regards, Max
2016-07-19 18:33 GMT+02:00 Mohamed kharrat med_khr@yahoo.fr:
Hi, i have created a database in BaseX GUI but i did not understand how to use it inside FLWR query. So since i would like to create one FLWR query to query all my files in the database not only one file with doc() i have tried collection() is that right? (i have putted all my xml files inside path/ directory) This is my query:
let $d:= collection ("path/") let $r:= doc("myfile1.xml") for $d in $d// item/@qcode="tx" where $d//subj[text() contains text { 'Hal', 'Fade' } any] and $r/subj ="Berlin" return <results>$d/tit</results>
it shows me error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false().
what is that error about?
Thank you Best regards
Thank you, it works :)What about the error? error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false().Any idea please?
De : Maximilian Gärber mgaerber@arcor.de À : Mohamed kharrat med_khr@yahoo.fr Cc : BaseX Talk basex-talk@mailman.uni-konstanz.de Envoyé le : Mardi 19 juillet 2016 17h44 Objet : Re: [basex-talk] querying database
Hi,
you do not need to use doc() or collection() if your documents are stored in a database.
The documents are just nodes as well, so doing something like:
let $db := db:open('some-db') for $d in $db//item/@qcode="tx" return $d
would return the items from all nodes (all files)
BTW: I guess you want: $db// item[@qcode="tx"]
Regards, Max
2016-07-19 18:33 GMT+02:00 Mohamed kharrat med_khr@yahoo.fr:
Hi, i have created a database in BaseX GUI but i did not understand how to use it inside FLWR query. So since i would like to create one FLWR query to query all my files in the database not only one file with doc() i have tried collection() is that right? (i have putted all my xml files inside path/ directory) This is my query:
let $d:= collection ("path/") let $r:= doc("myfile1.xml") for $d in $d// item/@qcode="tx" where $d//subj[text() contains text { 'Hal', 'Fade' } any] and $r/subj ="Berlin" return <results>$d/tit</results>
it shows me error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false().
what is that error about?
Thank you Best regards
$d// item/@qcode="tx"
…returns a boolean value (true or false). Hence,
for $d in $d// item/@qcode="tx"
is the same as
for $d in true()
or
for $d in false()
As a result,
$d//subj
will give you an error (node expected, boolean found).
On Tue, Jul 19, 2016 at 7:16 PM, Mohamed kharrat med_khr@yahoo.fr wrote:
Thank you, it works :) What about the error? error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false(). Any idea please?
De : Maximilian Gärber mgaerber@arcor.de À : Mohamed kharrat med_khr@yahoo.fr Cc : BaseX Talk basex-talk@mailman.uni-konstanz.de Envoyé le : Mardi 19 juillet 2016 17h44 Objet : Re: [basex-talk] querying database
Hi,
you do not need to use doc() or collection() if your documents are stored in a database.
The documents are just nodes as well, so doing something like:
let $db := db:open('some-db') for $d in $db//item/@qcode="tx" return $d
would return the items from all nodes (all files)
BTW: I guess you want: $db// item[@qcode="tx"]
Regards, Max
2016-07-19 18:33 GMT+02:00 Mohamed kharrat med_khr@yahoo.fr:
Hi, i have created a database in BaseX GUI but i did not understand how to use it inside FLWR query. So since i would like to create one FLWR query to query all my files in the database not only one file with doc() i have tried collection() is that right? (i have putted all my xml files inside path/ directory) This is my query:
let $d:= collection ("path/") let $r:= doc("myfile1.xml") for $d in $d// item/@qcode="tx" where $d//subj[text() contains text { 'Hal', 'Fade' } any] and $r/subj ="Berlin" return <results>$d/tit</results>
it shows me error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false().
what is that error about?
Thank you Best regards
ok i understand now. In fact i am looking for results which have this condition of qcode=tx . I do not want to know if it's true or false.
On Tue, Jul 19, 2016 at 6:23 PM +0100, "Christian Grün" christian.gruen@gmail.com wrote:
$d// item/@qcode="tx"
…returns a boolean value (true or false). Hence,
for $d in $d// item/@qcode="tx"
is the same as
for $d in true()
or
for $d in false()
As a result,
$d//subj
will give you an error (node expected, boolean found).
On Tue, Jul 19, 2016 at 7:16 PM, Mohamed kharrat wrote:
Thank you, it works :) What about the error? error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false(). Any idea please?
De : Maximilian Gärber À : Mohamed kharrat Cc : BaseX Talk Envoyé le : Mardi 19 juillet 2016 17h44 Objet : Re: [basex-talk] querying database
Hi,
you do not need to use doc() or collection() if your documents are stored in a database.
The documents are just nodes as well, so doing something like:
let $db := db:open('some-db') for $d in $db//item/@qcode="tx" return $d
would return the items from all nodes (all files)
BTW: I guess you want: $db// item[@qcode="tx"]
Regards, Max
2016-07-19 18:33 GMT+02:00 Mohamed kharrat :
Hi, i have created a database in BaseX GUI but i did not understand how to use it inside FLWR query. So since i would like to create one FLWR query to query all my files in the database not only one file with doc() i have tried collection() is that right? (i have putted all my xml files inside path/ directory) This is my query:
let $d:= collection ("path/") let $r:= doc("myfile1.xml") for $d in $d// item/@qcode="tx" where $d//subj[text() contains text { 'Hal', 'Fade' } any] and $r/subj ="Berlin" return $d/tit
it shows me error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false().
what is that error about?
Thank you Best regards
ok i understand now. In fact i am looking for results which have this condition of qcode=tx . I do not want to know if it's true or false.
Perfect, so use the predicate, as suggested by Max
$d// item[@qcode="tx"]
For more details, please spend some time on an XPath/XQuery primer, such as http://www.w3schools.com/xsl/xpath_intro.asp.
Thank you it works.Just a last question please.i need to write a query which means: return titles of all docs in database where the item/qcode ="tx"and where one of the subject name contains any one of those string: "FH" or "HG" let $db := db:open('mybase')for $x in $db//item[@qcode="tx"]where $db//subject/name[text() contains text{ "FH","HG"}any]return<results>{$db//title}</results> I think this query is wrong
De : Maximilian Gärber mgaerber@arcor.de À : Mohamed kharrat med_khr@yahoo.fr Cc : BaseX Talk basex-talk@mailman.uni-konstanz.de Envoyé le : Mardi 19 juillet 2016 17h44 Objet : Re: [basex-talk] querying database
Hi,
you do not need to use doc() or collection() if your documents are stored in a database.
The documents are just nodes as well, so doing something like:
let $db := db:open('some-db') for $d in $db//item/@qcode="tx" return $d
would return the items from all nodes (all files)
BTW: I guess you want: $db// item[@qcode="tx"]
Regards, Max
2016-07-19 18:33 GMT+02:00 Mohamed kharrat med_khr@yahoo.fr:
Hi, i have created a database in BaseX GUI but i did not understand how to use it inside FLWR query. So since i would like to create one FLWR query to query all my files in the database not only one file with doc() i have tried collection() is that right? (i have putted all my xml files inside path/ directory) This is my query:
let $d:= collection ("path/") let $r:= doc("myfile1.xml") for $d in $d// item/@qcode="tx" where $d//subj[text() contains text { 'Hal', 'Fade' } any] and $r/subj ="Berlin" return <results>$d/tit</results>
it shows me error: [XPTY0019] descendant::subj: node expected, xs:boolean found: false().
what is that error about?
Thank you Best regards
basex-talk@mailman.uni-konstanz.de