4. p:file-delete

The p:file-delete step deletes a file or a directory.

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

The p:file-delete step attempts to delete the file or directory named in href.

Conformant processors must support URIs whose scheme is file for the href option of p:file-delete. It is implementation-defined what other schemes are supported by p:file-delete, and what the interpretation of ‘directory’, ‘file’ and ‘contents’ is for those schemes. It is a dynamic error (err:XC0142) if an implementation does not support p:file-delete 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-delete 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:XC0143) if p:file-delete is not available to the step due to access restrictions in the environment in which the pipeline is run.

If href specifies a directory, it can only be deleted if the recursive option is true or if the specified directory is empty.

If the delete is successful, the step returns a c:result element containing the absolute URI of the deleted file or directory.

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 or directory.

  • It is a dynamic error (err:XC0113) if an attempt is made to delete a non-empty directory and the recursive option was set to false.

Document properties

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