Hi,
I would like to have a nested xquery, but I am not sure if this is possible at all:
When a user searches the corpus, he can save the hits he likes most. The result for the query is a form with checkboxes. The node IDs together with the query and a time stamp are saved in a second collection. This collections looks like this:
<collection> <entry time="2012-03-04T17:24:53"> <node>1434455</node> <query>[text() contains text ('Daumen' ftand 'Auge' ftand 'halten') using stemming using language "de" distance at most 10 words ordered]</query> <person>xyz</person> <phraseme>Ad0024</phraseme> <selected>yes</selected> </entry> <entry time="2012-03-04T17:24:53"> <node>1475764</node> <query>[text() contains text ('Daumen' ftand 'Auge' ftand 'halten') using stemming using language "de" distance at most 10 words ordered]</query> <person>abc</person> <phraseme>Ad0024</phraseme> <selected>no</selected> </entry> </collection>
When the user searches again with a different query, he will see the results as for the first search and is able to save only those that are not in the hit-collection. This is controlled by this part in the "return" part of the xquery in my perl client:
{ if (not (db:open("collect")//node[text() = $node and ../phraseme[text() = "$phraseme"] and ../selected[text() = "yes"]])) then <input type="checkbox" name="NODE" value="{\node}"/> else "X" }
Already saved hits get an "X" and new hits get the checkbox.
For documentation, I would like to collect all queries a node could be found with. Thus, instead of printing "X", I would like to add an additional query-element to the entry-element, i.e., something like
insert node <query>$query</query> after /collection/entry/node[text() = "$node" and ../phraseme[text() = "$phraseme" and ../selected[text() = "yes"]]]
to get:
<collection> <entry time="2012-03-04T17:24:53"> <node>1434455</node> <query>[text() contains text ('Daumen' ftand 'Auge' ftand 'halten') using stemming using language "de" distance at most 10 words ordered]</query> <query>[text() contains text ('Daumen' ftand 'Auge') using stemming using language "de" distance at most 10 words ordered]</query> <query>[text() contains text ('Daumen' ftand 'Auge') distance at most 10 words ordered]</query> <person>xyz</person> <phraseme>Ad0024</phraseme> <selected>yes</selected> </entry> <entry time="2012-03-04T17:24:53"> <node>1475764</node> <query>[text() contains text ('Daumen' ftand 'Auge' ftand 'halten') using stemming using language "de" distance at most 10 words ordered]</query> <person>abc</person> <phraseme>Ad0024</phraseme> <selected>no</selected> </entry> </collection>
However, I am not sure if it is possible at all to mix displaying (in the "then" part) and updating (in the "else" part) -- although I would like to update a different collection than I am searching. If it is possible, I guess I have to include the name of the collection for insertion by using db:open? Is it necessary to specify the exact place for insertion (as in my example) as this should be already determined by the condition?
Best regards
Cerstin
Hi Cerstin,
However, I am not sure if it is possible at all to mix displaying
(in the "then" part) and updating (in the "else" part)
True - that's actually a limitation of the update specification, wich forbids mixing updating and non-updating expressions. You can find some information on it in our documentation [1] and in the actual XQuery specification [2]. As a consequence you have to insert the new query element during a consecutive query.
If it is possible, I guess I have to include the name of the collection for
insertion
by using db:open? Is it necessary to specify the exact place for insertion
(as in
my example) as this should be already determined by the condition?
Declaring a variable via the Let expression would help to specify the exact location only once ... but of course as you have to insert the node during a second query it's not helping here.
Sorry that I can't provide you with a better solution ... feel free to ask for more.
Best regards, Lukas
[1] http://docs.basex.org/wiki/Update#Returning_Results [2] http://www.w3.org/TR/xquery-update-10/#id-conditional-expr
Hi Lukas,
Zitat von Lukas Kircher lukaskircher1@googlemail.com:
However, I am not sure if it is possible at all to mix displaying
(in the "then" part) and updating (in the "else" part)
True - that's actually a limitation of the update specification, wich forbids mixing updating and non-updating expressions. You can find some information on it in our documentation [1] and in the actual XQuery specification [2]. As a consequence you have to insert the new query element during a consecutive query.
OK, thanks for clarification.
Cerstin
basex-talk@mailman.uni-konstanz.de