2013-04-11 73 views
0

我已經在存在數據庫上執行了一個xquery。現在我想將輸出打印在像csv或excel文件這樣的文件中,怎麼做才能完成。將存儲數據庫輸出打印到文件

我可以用HTML格式打印輸出,但有什麼辦法可以爲此生成一個文件。

+0

我猜測,這是可以做到使用存在文件模塊-db,但我找不到任何文檔來使用該模塊。 – abhi191 2013-04-11 10:55:12

+0

http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/file&location=java:org.exist.xquery.modules.file.FileModule – 2013-04-11 13:05:35

回答

1

使用FileModule,其中有一個serialize功能:

 
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. 

參考