5. p:file-info

The p:file-info step returns information about a file, directory or other file system object.

<p:declare-step type="p:file-info">
     <p:output port="result" primary="true" content-types="application/xml"/>
     <p:option name="href" required="true" as="xs:anyURI"/>        
     <p:option name="fail-on-error" as="xs:boolean" select="true()"/>
     <p:option name="override-content-types" as="array(array(xs:string))?"/>
</p:declare-step>

The p:file-info step returns information about the file, directory or other file system object named in the href option.

Conformant processors must support URIs whose scheme is file for the href option of p:file-info. It is implementation-defined what other schemes are supported by p:file-info, and what the interpretation of ‘directory’, ‘file’ and ‘contents’ is for those schemes. It is a dynamic error (err:XC0134) if an implementation does not support p:file-info for a specified scheme.

If href is relative, it is made absolute against the base URI of the element on which it is specified (p:with-option or p:file-info in the case of a syntactic shortcut value). It is a dynamic error (err:XD0064) if the base URI is not both absolute and valid according to [RFC 3986]. It is a dynamic error (err:XC0135) if p:file-info is not available to the step due to access restrictions in the environment in which the pipeline is run.

If the href option is a file: URI, the step returns:

  • If href option references a file: A c:file element with standard attributes (see below).

  • If href option references a directory: A c:directory element with standard attributes (see below).

  • If href option references any other file system object: Implementation defined (for example an c:other or c:device element). It is advised to use the standard attributes (see below) if applicable.

The override-content-types option can be used to partially override the content-type determination mechanism for files. This works just like with the override-content-types option of p:archive-manifest and p:unarchive, except that the regular expression matching is done against the absolute URI of the file.

The following attributes are standard on a returned c:file or c:directory element. All attributes are optional and must be absent if not applicable. Additional implementation-defined attributes may be present, but they must be in a namespace.

AttributeTypeDescription
readablexs:booleantrue if the object is readable.
writablexs:booleantrue if the object file is writable.
hiddenxs:booleantrue if the object is hidden.
last-modifiedxs:dateTimeThe last modification time of the object expressed in UTC.
sizexs:integerThe size of the object in bytes.
content-typexs:stringThe content type, if the object is a file.

If an error occurs and fail-on-error is false, the step returns a c:error element which may contain additional, implementation-defined, information about the nature of the error.

If an error occurs and fail-on-error is true, one of the following errors is raised:

  • It is a dynamic error (err:XD0011) if the resource referenced by the href option does not exist, cannot be accessed or is not a file, directory or other file system object.

Document properties

The resulting document has no properties apart from content-type. In particular, it has no base-uri.