The "QueryExample" app contains the following statement:
String query = "for $x in doc('etc/xml/input.xml')//li return $x";
What is the semantics of that? Does it mean that the (potentially huge) file `input.xml' will be converted into a binary database every time that statement is executed?
The above exemplifies a very common problem with XML query examples: The authors provide ONE step when we need TWO:
(1) An initialization of the XML tree, done ONCE.
(2) A retrieval statement, which is done MULTIPLE times.
In short, let's say I have a binary database called "Input" (derived from `input.xml'). How can I refer to it in the QueryExample app?
TIA,
-Ramon
ps: Sorry for the multiple posts before. The anti-spam feature is confusing.
ps: Sorry for the multiple posts before. The anti-spam feature is confusing.
Thanks for the info; the feedback page has been fixed again.
The "QueryExample" app contains the following statement:
String query = "for $x in doc('etc/xml/input.xml')//li return $x";
What is the semantics of that? Does it mean that the (potentially huge) file `input.xml' will be converted into a binary database every time that statement is executed?
The XQuery specification doesn't contain information on how to interact with databases. This is why every DBMS pursues its own strategy. BaseX offers numerous approaches as well; the easiest thing to do is to explicitly create a single database for the document in question:
new CreateDB("input", "etc/xml/input.xml").execute(context);
Next, you can use the doc("...") or basex:db("...") functions to access the database:
new XQuery("for $d in doc('input') ...").execute(context);
Hth, Christian
basex-talk@mailman.uni-konstanz.de