I have executed an xquery on the exist-db. Now I want to print the output in a file like a csv or an excel file, how can it be done.
I can print the output in an HTML format but is there any way to to generate a file for the same.
I have executed an xquery on the exist-db. Now I want to print the output in a file like a csv or an excel file, how can it be done.
I can print the output in an HTML format but is there any way to to generate a file for the same.
Use the FileModule, which has a serialize
function:
file:serialize file:serialize($node-set as node()*, $path as item(), $parameters as xs:string*, $append as xs:boolean) as xs:boolean? Writes the node set into a file on the file system, optionally appending to it. $parameters contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from. This method is only available to the DBA role. Parameters: $node-set* The contents to write to the file system. $path The full path or URI to the file $parameters* The serialization parameters specified as key-value pairs $append Should content be appended? Returns: xs:boolean? : true on success - false if the specified file can not be created or is not writable. The empty sequence is returned if the argument sequence is empty.
References