Changes

Jump to navigation Jump to search
1,218 bytes removed ,  15:51, 26 May 2012
no edit summary
=Conventions=
All functions in this module are assigned to the <code>{{Code|http://expath.org/ns/file</code> }} namespace, which is statically bound to the <code>{{Code|file</code> }} prefix.<br/>All errors are assigned to the <code>{{Code|http://expath.org/ns/error</code> }} namespace, which is statically bound to the <code>{{Code|exerr</code> }} prefix.
=Variables=
|-
| width='90' | '''Signatures'''
|<code><b>{{Code|'''$file:directory-separator</b> ''' as xs:string</code>}}<br />
|-
| '''Summary'''
|-
| width='90' | '''Signatures'''
|<code><b>{{Code|'''$file:path-separator</b> ''' as xs:string</code>}}<br />
|-
| '''Summary'''
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:exists</b>(|$path as xs:string) as |xs:boolean</code>}}<br />
|-
| '''Summary'''
|Returns an <code>{{Code|xs:boolean</code> }} indicating whether a file or directory specified by <code>{{Code|$path</code> }} exists in the file system.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:is-directory</b>(|$path as xs:string) as |xs:boolean</code>}}<br />
|-
| '''Summary'''
|Returns an <code>{{Code|xs:boolean</code> }} indicating whether the argument <code>{{Code|$path</code> }} points to an existing directory.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:is-file</b>(|$path as xs:string) as |xs:boolean</code>}}<br />
|-
| '''Summary'''
|Returns an <code>{{Code|xs:boolean</code> }} indicating whether the argument <code>{{Code|$path</code> }} points to an existing file.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:last-modified</b>(|$path as xs:string) as |xs:dateTime</code>}}<br />
|-
| '''Summary'''
|Retrieves the timestamp of the last modification of the file or directory specified by <code>{{Code|$path</code>}}.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0001|#Errors|FOFL0001]]</b> is raised if }} the specified path does not exist.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:size</b>(|$file as xs:string) as |xs:integer</code>}}<br />
|-
| '''Summary'''
|Returns the size, in bytes, of the file specified by <code>{{Code|$path</code>}}.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0001|#Errors|FOFL0001]]</b> is raised if }} the specified file does not exist.<br /><b>[[{{Error|FOFL0004|#Errors|FOFL0004]]</b> is raised if }} the specified file points to a directory.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:base-name</b>(|$path as xs:string) as |xs:string</code>}}<br /><code><b>{{Func|file:base-name</b>(|$path as xs:string, $suffix as xs:string) as |xs:string</code>}}<br />
|-
| '''Summary'''
|Returns the base-name of the path specified by <code>{{Code|$path</code>}}, which is the component after the last directory separator.<br />If <code>{{Code|$suffix</code> }} is specified, it will be trimmed from the end of the result.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:dir-name</b>(|$path as xs:string) as |xs:string</code>}}<br />
|-
| '''Summary'''
|Returns the parent directory of the path specified by <code>{{Code|$path</code>}}, which is the component before the last directory separator.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:path-to-native</b>(|$path as xs:string) as |xs:string</code>}}<br />
|-
| '''Summary'''
|Transforms the <code>{{Code|$path</code> }} argument to its native representation on the operating system.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the specified path cannot be transformed to its native representation.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:resolve-path</b>(|$path as xs:string) as |xs:string</code>}}<br />
|-
| '''Summary'''
|Transforms the <code>{{Code|$path</code> }} argument to an absolute operating system path.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:path-to-uri</b>(|$path as xs:string) as |xs:string</code>}}<br />
|-
| '''Summary'''
|Transforms the path specified by <code>{{Code|$path</code> }} into a URI with the <code>{{Code|file://</code> }} scheme.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:list</b>(|$directory as xs:string) as |xs:string*</code>}}<br /><code><b>{{Func|file:list</b>(|$directory as xs:string, $recursive as xs:boolean) as |xs:string*</code>}}<br /><code><b>{{Func|file:list</b>(|$directory as xs:string, $recursive as xs:boolean, $pattern as xs:string) as |xs:string*</code>}}<br />
|-
| '''Summary'''
|Lists all files and directories found in the specified <code>{{Code|$directory</code>}}. The returned paths are relative to the provided path.<br />The optional parameter <code>{{Code|$recursive</code> }} specifies whether sub-directories will be traversed, too.<br />The optional parameter <code>{{Code|$pattern</code> }} defines a file name pattern in the [http://en.wikipedia.org/wiki/Glob_(programming) glob syntax]. If present, only those files and directories are returned that correspond to the pattern. Several patterns can be separated with a comma (<code>{{Code|,</code>}}).<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0003|#Errors|FOFL0003]]</b> is raised if }} the specified path does not point to a directory.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:create-directory</b>(|$directory as xs:string) as |empty-sequence()</code>}}<br />
|-
| '''Summary'''
|Recursively creates the directories specified by <code>{{Code|$directory</code>}}.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0002|#Errors|FOFL0002]]</b> is raised if }} a file with the same path already exists.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:delete</b>(|$path as xs:string) as |empty-sequence()</code>}}<br /><code><b>{{Func|file:delete</b>(|$path as xs:string, $recursive as xs:boolean) as |empty-sequence()</code>}}<br />
|-
| '''Summary'''
|Recursively deletes a file or directory specified by <code>{{Code|$path</code>}}.<br />The optional parameter <code>{{Code|$recursive</code> }} specifies whether sub-directories will be deleted, too.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0001|#Errors|FOFL0001]]</b> is raised if }} the specified path does not exist.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:read-text</b>(|$path as xs:string) as |xs:string</code>}}<br /><code><b>{{Func|file:read-text</b>(|$path as xs:string, $encoding as xs:string) as |xs:string</code>}}<br />
|-
| '''Summary'''
|Reads the textual contents of the file specified by <code>{{Code|$path</code> }} and returns it as a <code>{{Code|xs:string</code>}}.<br />The optional parameter <code>{{Code|$encoding</code> }} defines the encoding of the file.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0001|#Errors|FOFL0001]]</b> is raised if }} the specified file does not exist.<br /><b>[[{{Error|FOFL0004|#Errors|FOFL0004]]</b> is raised if }} the specified path is a directory.<br /><b>[[{{Error|FOFL0005|#Errors|FOFL0005]]</b> is raised if }} the specified encoding is not supported, or unknown.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:read-text-lines</b>(|$path as xs:string) as |xs:string</code>}}<br /><code><b>{{Func|file:read-text-lines</b>(|$path as xs:string, $encoding as xs:string) as |xs:string*</code>}}<br />
|-
| '''Summary'''
|Reads the textual contents of the file specified by <code>{{Code|$path</code> }} and returns it as a sequence of <code>{{Code|xs:string</code> }} items.<br />The optional parameter <code>{{Code|$encoding</code> }} defines the encoding of the file.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0001|#Errors|FOFL0001]]</b> is raised if }} the specified file does not exist.<br /><b>[[{{Error|FOFL0004|#Errors|FOFL0004]]</b> is raised if }} the specified path is a directory.<br /><b>[[{{Error|FOFL0005|#Errors|FOFL0005]]</b> is raised if }} the specified encoding is not supported, or unknown.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:read-binary</b>(|$path as xs:string) as |xs:base64Binary</code>}}<br />
|-
| '''Summary'''
|Reads the binary content of the file specified by <code>{{Code|$path</code> }} and returns as a <code>{{Code|xs:base64Binary</code>}}.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0001|#Errors|FOFL0001]]</b> is raised if }} the specified file does not exist.<br /><b>[[{{Error|FOFL0004|#Errors|FOFL0004]]</b> is raised if }} the specified path is a directory.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:write</b>(|$path as xs:string, $items as item()*) as |empty-sequence()</code>}}<br /><code><b>{{Func|file:write</b>(|$path as xs:string, $items as item()*, $params as xs:node()*) as |empty-sequence()</code>}}<br />
|-
| '''Summary'''
|Writes a sequence of <code>{{Code|$items</code> }} to a file specified by <code>{{Code|$path</code>}}. If the specified file already exists, it will be overwritten.<br />The optional argument <code>{{Code|$params</code> }} is used to set the serialization parameters (see [[Serialization]] for more details).It can be specified as<br />* <code>{{Code|element(serialization-parameters)</code>}}: <code>{{Code|&lt;serialization-parameters/&gt;</code> }} must be used as root element, and the parameters are specified as child nodes, with the element name representing the serialization parameter and the attribute <code>{{Code|value</code> }} representing its value:<br /><code>{{Code|&lt;serialization-parameters xmlns="http://www.w3.org/2010/xslt-xquery-serialization"&gt;<br/>&nbsp;&nbsp;&lt;method value='xml'/&gt;<br/>&nbsp;&nbsp;&lt;cdata-section-elements value="div"/&gt;<br/>&nbsp;&nbsp;...<br/>&lt;/serialization-parameters&gt;</code>}}* [[Map Module|map structure]]: all parameters can be directly represented as key/value pairs:<br /><code>{{Code|map { "method" := "xml", "cdata-section-elements" := "div", ... </code>}}}<br/>
|-
| '''Errors'''
|<b>[[{{Error|FOFL0004|#Errors|FOFL0004]]</b> is raised if }} the specified path is a directory.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:write-binary</b>(|$path as xs:string, $items as xs:base64Binary*) as |empty-sequence()</code>}}<br />
|-
| '''Summary'''
|Writes a sequence of <code>{{Code|xs:basex64Binary</code> <code>}} {{Code|$items</code> }} to a file specified by <code>{{Code|$path</code>}}. If the specified file already exists, it will be overwritten.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0004|#Errors|FOFL0004]]</b> is raised if }} the specified path is a directory.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:append</b>(|$path as xs:string, $items as item()*) as |empty-sequence()</code>}}<br /><code><b>{{Func|file:append</b>(|$path as xs:string, $items as item()*, $params as xs:node()*) as |empty-sequence()</code>}}<br />
|-
| '''Summary'''
|Appends a sequence of <code>{{Code|$items</code> }} to a file specified by <code>{{Code|$path</code>}}. If the specified file does not exists, a new file is created.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0004|#Errors|FOFL0004]]</b> is raised if }} the specified path is a directory.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:append-binary</b>(|$path as xs:string, $items as xs:base64Binary*) as |empty-sequence()</code>}}<br />
|-
| '''Summary'''
|Appends a sequence of <code>{{Code|xs:basex64Binary</code> <code>}} {{Code|$items</code> }} to a file specified by <code>{{Code|$path</code>}}. If the specified file does not exists, a new file is created.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0004|#Errors|FOFL0004]]</b> is raised if }} the specified path is a directory.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:copy</b>(|$source as xs:string, $target as xs:string) as |empty-sequence()</code>}}<br />
|-
| '''Summary'''
|Copies a file specified by <code>{{Code|$source</code> }} to the file or directory specified by <code>{{Code|$target</code>}}. If the target represents an existing file, it will be overwritten. No operation will be performed if the source and target path are equal.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0001|#Errors|FOFL0001]]</b> is raised if }} the specified source does not exist.<br /><b>[[{{Error|FOFL0002|#Errors|FOFL0002]]</b> is raised if }} the specified source is a directory and the target is a file.<br /><b>[[{{Error|FOFL0003|#Errors|FOFL0003]]</b> is raised if }} the parent of the specified target is no directory.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|file:move</b>(|$source as xs:string, $target as xs:string) as |empty-sequence()</code>}}<br />
|-
| '''Summary'''
|Moves or renames the file or directory specified by <code>{{Code|$source</code> }} to the path specified by <code>{{Code|$target</code>}}. No operation will be performed if the source and target path are equal.<br />
|-
| '''Errors'''
|<b>[[{{Error|FOFL0001|#Errors|FOFL0001]]</b> is raised if }} the specified source does not exist.<br /><b>[[{{Error|FOFL0002|#Errors|FOFL0002]]</b> is raised if }} the specified source is a directory and the target is a file.<br /><b>[[{{Error|FOFL0003|#Errors|FOFL0003]]</b> is raised if }} the parent of the specified target is no directory.<br /><b>[[{{Error|FOFL9999|#Errors|FOFL9999]]</b> is raised if }} the operation fails for some other reason.<br />
|}
! width="95%"|Description
|-
|<code>{{Code|FOFL0001</code>}}
|A specified path does not exist.
|-
|<code>{{Code|FOFL0002</code>}}
|A file with the same path already exists.
|-
|<code>{{Code|FOFL0003</code>}}
|The specified path does not point to a directory.
|-
|<code>{{Code|FOFL0004</code>}}
|The specified path is a directory.
|-
|<code>{{Code|FOFL0005</code>}}
|The specified encoding is not supported, or unknown.
|-
|<code>{{Code|FOFL9999</code>}}
|The operation fails for some other reason specific to the operating system.
|}
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu