XQuery/File Transfer Client

From Wikibooks, open books for an open world
Jump to navigation Jump to search

File Transfer Client[edit | edit source]

The EXPath File Transfer Client provides a common interface for both FTP and SFTP (SSH).

Installation[edit | edit source]

Make sure that the following Jar files have been added to your $EXIST_HOME/lib/extensions:

  • expath-ft-client.jar
  • jsch-0.1.44.jar

The first jar file is the Java Archive file that contains the XQuery module interfaces. The second jar file is the module that provides the Secure Shell protocol support. See http://www.jcraft.com/jschfor further details.

<module uri="http://exist-db.org/xquery/httpclient" class="org.exist.xquery.modules.httpclient.HTTPClientModule" />

The following is a temporary link to the File Transfer client interface specification:


Getting remote XML files[edit | edit source]

(: this is a safe version of get remote XML file and parse :)
declare function local:get-remote-file-safe($connection as xs:long, $path as xs:string) as node() {
let $binary-file := ft-client:retrieve-resource($connection, $path)
let $string-of-file := util:binary-to-string($binary-file)
try {util:parse($string-of-file)}
        catch exerr:EXXQDY0002 {<error>The input file is not well formed.</error>}
        catch * {<error>Unknown parse error on input file.  The input could not be parsed.</error>}