simplest possible FLOWR specifying a database

Saturday, 12 October 2019 · 6 messages · last reply 13 Oct 2019
MH
Martin Honnenin reply to thufir, 12 Oct 2019, 12:1112 Oct 2019 10:56 #
Quoted text · thufir · 9 lines
Am 12.10.2019 um 10:11 schrieb thufir: > nevermind, it's: > > let $db := db:open("com.w3schools.books") > return $db/bookstore > > I thought it was unusual because of db:open. > >
You would not even need the "let .. return", if you simply want a short expression you can also use
   db:open("com.w3schools.books")/bookstore
CG
Christian Grünin reply to thufir, 12 Oct 2019, 12:1112 Oct 2019 11:29 #
On top of the query (in the query prolog), you can bind your database to the context. After that, there’ll be no need to bind it to a variable: declare context item := db:open("com.w3schools.books"); /bookstore
Quoted text · thufir · 37 lines
On Sat, Oct 12, 2019 at 10:11 AM thufir <hawat.thufir at gmail.com> wrote: > > nevermind, it's: > > let $db := db:open("com.w3schools.books") > return $db/bookstore > > I thought it was unusual because of db:open. > > > -Thufir > > On 2019-10-12 12:50 a.m., thufir wrote: > > these FLWOR .xq files work as is: > > > > let $db := db:open("com.w3schools.books") > > for $x in $db/bookstore > > return $x > > > > > > or > > > > <new_catalog>{ > > let $db := db:open("com.w3schools.books") > > for $x in $db/bookstore/book > > return <new_book>{$x/title,$x/author}</new_book> > > }</new_catalog> > > > > > > Probably a silly question, but, rather than, as in the first query, > > using $x can I not somehow specify just "/"? > > > > > > > > thanks, > > > > Thufir
T
thufir12 Oct 2019 11:50 #
these FLWOR .xq files work as is:
let $db := db:open("com.w3schools.books")
for $x in $db/bookstore
return $x
or
<new_catalog>{
let $db := db:open("com.w3schools.books")
for $x in $db/bookstore/book
return <new_book>{$x/title,$x/author}</new_book>
}</new_catalog>
Probably a silly question, but, rather than, as in the first query, using $x can I not somehow specify just "/"? thanks, Thufir
T
thufir12 Oct 2019 12:11 #
nevermind, it's:
let $db := db:open("com.w3schools.books")
return $db/bookstore
I thought it was unusual because of db:open. -Thufir
Quoted text · thufir · 25 lines
On 2019-10-12 12:50 a.m., thufir wrote: > these FLWOR .xq files work as is: > > let $db := db:open("com.w3schools.books") > for $x in $db/bookstore > return $x > > > or > > <new_catalog>{ > let $db := db:open("com.w3schools.books") > for $x in $db/bookstore/book > return <new_book>{$x/title,$x/author}</new_book> > }</new_catalog> > > > Probably a silly question, but, rather than, as in the first query, > using $x can I not somehow specify just "/"? > > > > thanks, > > Thufir
T
thufirin reply to Christian Grün, 12 Oct 2019, 11:2913 Oct 2019 00:49 #
that's interesting. what's item in this example, and how can it be referenced? thanks, Thufir
Quoted text · Christian Grün · 47 lines
On 2019-10-12 2:29 a.m., Christian Grün wrote: > On top of the query (in the query prolog), you can bind your database > to the context. After that, there’ll be no need to bind it to a > variable: > > declare context item := db:open("com.w3schools.books"); > /bookstore > > > > On Sat, Oct 12, 2019 at 10:11 AM thufir <hawat.thufir at gmail.com> wrote: >> >> nevermind, it's: >> >> let $db := db:open("com.w3schools.books") >> return $db/bookstore >> >> I thought it was unusual because of db:open. >> >> >> -Thufir >> >> On 2019-10-12 12:50 a.m., thufir wrote: >>> these FLWOR .xq files work as is: >>> >>> let $db := db:open("com.w3schools.books") >>> for $x in $db/bookstore >>> return $x >>> >>> >>> or >>> >>> <new_catalog>{ >>> let $db := db:open("com.w3schools.books") >>> for $x in $db/bookstore/book >>> return <new_book>{$x/title,$x/author}</new_book> >>> }</new_catalog> >>> >>> >>> Probably a silly question, but, rather than, as in the first query, >>> using $x can I not somehow specify just "/"? >>> >>> >>> >>> thanks, >>> >>> Thufir
BD
Bridger Dyson-Smith13 Oct 2019 01:17 #
Hi thufir, The specification might be helpful here [1,2], but essentially it is the thing being processed, given as a sort of global scope. HTH! Best, Bridger [1] https://www.w3.org/TR/xquery-31/#id-context-item-expression [2] https://www.w3.org/TR/xquery-31/#dt-context-item
Quoted text · thufir · 57 lines
On Sat, Oct 12, 2019, 4:49 PM thufir <hawat.thufir at gmail.com> wrote: > that's interesting. what's item in this example, and how can it be > referenced? > > > thanks, > > Thufir > > On 2019-10-12 2:29 a.m., Christian Grün wrote: > > On top of the query (in the query prolog), you can bind your database > > to the context. After that, there’ll be no need to bind it to a > > variable: > > > > declare context item := db:open("com.w3schools.books"); > > /bookstore > > > > > > > > On Sat, Oct 12, 2019 at 10:11 AM thufir <hawat.thufir at gmail.com> wrote: > >> > >> nevermind, it's: > >> > >> let $db := db:open("com.w3schools.books") > >> return $db/bookstore > >> > >> I thought it was unusual because of db:open. > >> > >> > >> -Thufir > >> > >> On 2019-10-12 12:50 a.m., thufir wrote: > >>> these FLWOR .xq files work as is: > >>> > >>> let $db := db:open("com.w3schools.books") > >>> for $x in $db/bookstore > >>> return $x > >>> > >>> > >>> or > >>> > >>> <new_catalog>{ > >>> let $db := db:open("com.w3schools.books") > >>> for $x in $db/bookstore/book > >>> return <new_book>{$x/title,$x/author}</new_book> > >>> }</new_catalog> > >>> > >>> > >>> Probably a silly question, but, rather than, as in the first query, > >>> using $x can I not somehow specify just "/"? > >>> > >>> > >>> > >>> thanks, > >>> > >>> Thufir >

⚡Generated with XQuery