Sorry for the delayed response...
I was aware of the empty collection and default (but maybe not clear on
it)...
This query works:
String myXQueryString ="for $doc in collection() where matches(document-uri($doc),
'" + DocID +
"') return $doc";
return (new XQuery(myXQueryString).execute(context));
Note that it too uses an empty collection clause, but always returns a
document. So why do I need to specify a collection in this case? (It
also confirms that I do have some documents stored in the database to
actually query.)
-AJ
On 3/9/2017 3:02 AM, Michael Seiferle wrote:
Hi Aaron,
welcome to the list!
For BaseX to „open“ a collection you need to address it by URI; in
your case no URI is present, so BaseX loads the „default collection“
which is set to the currently opened database (I guess you have none
open :—)):
So usually you want to address your collection by name:
for $foo in collection(‚myFoos‘)
…
return $foo
Where each $foo resembles a document inside your collection.
In BaseX a collection usually resembles a database, so your first step
would be:
- Create a database that either is a single document or contains
multiple documents
So in SQL lingo I’d say you are basically missing your FROM ‚…‘ :-)
A good read might be: http://docs.basex.org/wiki/Databases it shows
the various ways of creating, returning and querying documents /
collections :-)
Best
Michael
Am 09.03.2017 um 00:30 schrieb Aaron Weber <awe...@comcast.net
<mailto:awe...@comcast.net>>:
Newbie alert.
I'm trying to get my feet wet with BaseX, and in doing so, am trying
to understand XQuery and how to apply it to a database full of
documents (not just a single document that is typically queried).
I am using Java and can post my code, but with a LocalSession, and a
query, the following produces 0 results.
For $doc in collection() return $doc
I realize there's no "where", and in the sql world that would match
all. Maybe not in XQuery?
Obviously just a test query, but I need to start somewhere. :-)
Thanks for any help!
--
AJ
--
Michael Seiferle, BaseX GmbH, http://www.basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Fon: +49 7531 916 82 77