Hi Cerstin,
the following query may help:
for $entry in $doc//entry let $next := $entry/following-sibling::entry[1] let $sc := $entry/following-sibling::secondquery [empty($next) or . << $next] return ( insert nodes $sc into $entry, delete nodes $sc )
Cheers, Christian ___________________________
On Tue, Mar 12, 2013 at 5:46 PM, Cerstin Elisabeth Mahlow cerstin.mahlow@unibas.ch wrote:
Hi,
after a lot of data has been gathered, I realized that my update-function has a bug. It's not a big deal fixing it, however, I don't know how to resort the existing data.
Essentially, I wanted to create this kind of data:
<collection> <entry> <node>123</node> <query>xyz</query> <secondquery>abc_1</secondquery> <secondquery>abc_2</secondquery> </entry> <entry> <node>456</node> <query>xyz</query> <secondquery>abc_1</secondquery> <secondquery>abc_3</secondquery> <secondquery>abc_4</secondquery> </entry> </collection>
However, the data looks like this:
<collection> <entry> <node>123</node> <query>xyz</query> </entry> <secondquery>abc_1</secondquery> <secondquery>abc_2</secondquery> <entry> <node>456</node> <query>xyz</query> </entry> <secondquery>abc_1</secondquery> <secondquery>abc_3</secondquery> <secondquery>abc_4</secondquery> </collection>
So, the secondqueries are stored just after the entry they belong to. How would I be able to move these data from "right after a particular node" to "just inside this particular node" using XQuery Update?
Thanks in advance and best regards
Cerstin
Dr. phil. Cerstin Mahlow
Universität Basel Departement Sprach- und Literaturwissenschaften Fachbereich Deutsche Sprach- und Literaturwissenschaft Nadelberg 4 4051 Basel Schweiz
Tel: +41 61 267 07 65 Fax: +41 61 267 34 40 Mail: cerstin.mahlow@unibas.ch Web: http://www.oldphras.net
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk