Hi Marco,
BaseX sounds like a good fit for your requirements to me :)
You dont say what your error is, but you have declared local:process-data as returning an element named <root> whereas the code is returning an element named <RMCollectionItemsDATA>. Perhaps it should be:
declare function local:process-data ($nodes as item()*) as element ( RMCollectionItemsDATA ) or ... as element ( * )
Also I suspect you want an additional \ in your o/p path declare variable $output := 'C:\DATAQUERY\BaseX\Q001\outputPROD**';
Regards /Andy ----------------------------------- declare variable $data := collection(PRODRMCollectionItems); declare variable $output := 'C:\DATAQUERY\BaseX\Q001\outputPROD**';
(:This is where all the work is happening:) declare function local:process-data ($nodes as item()*) as element ( *RMCollectionItemsDATA*) { <RMCollectionItemsDATA created="{current-dateTime()}"> { for $a in $nodes//artObjectGetResponse/artObject[objectNumber eq 'NG-NM-1395-A'] return <item>{$a}</item> } </RMCollectionItemsDATA> };
(:here we store stuff:) let $filename := concat($output, "marco.xml") return file:write($filename, local:process-data($data))
On 6 September 2018 at 16:13, Marco Roling marcoroling@hotmail.com wrote:
Dear all,
I am new on the block here, and trying to find my way around BaseX, which seems to meet my needs for my research on digital museum collection data analysis.
I have a very large collection of xml files (> 600000 files) that I am querying, and I want to write the returned result immediately in a file. The following xquery (see below) is not working, which probably comes as no surprise to you all.
But to get me started, I would like to have a simple example that works. Any example would do.
Hope anyone can help me out with this.
Thanks very much, best, Marco.
=====
declare variable $data := collection(PRODRMCollectionItems); declare variable $output := 'C:\DATAQUERY\BaseX\Q001\outputPROD';
(:This is where all the work is happening:) declare function local:process-data ($nodes as item()*) as element (root) {
<RMCollectionItemsDATA created="{current-dateTime()}"> { for $a in $nodes//artObjectGetResponse/artObject[objectNumber eq 'NG-NM-1395-A'] return <item>{$a}</item> } </RMCollectionItemsDATA> };
(:here we store stuff:) let $filename := concat($output, "marco.xml") return file:write($filename, local:process-data($data)) =====