0

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.

Joe Wicentowski
  • 5,159
  • 16
  • 26
abhi191
  • 65
  • 1
  • 1
  • 10
  • I am guessing that it can be done using the file module in exist-db, but I cannot find any documentation to use the module. – abhi191 Apr 11 '13 at 10:55
  • http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/file&location=java:org.exist.xquery.modules.file.FileModule – Leo Wörteler Apr 11 '13 at 13:05

1 Answers1

1

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

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265