8. p:file-create-tempfile

The p:file-create-tempfile step creates a temporary file.

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

The p:file-create-tempfile creates a temporary file. The temporary file is guaranteed not to already exist when the step is called.

If the href option is specified it must be the URI of an existing directory. The temporary file is created here. If there is no href option specified the location of the temporary file is implementation defined, usually the operating system's default location for temporary files.

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

If the prefix option is specified, the filename will begin with that prefix. If the suffix option is specified, the filename will end with that suffix.

If the delete-on-exit option is true, an attempt will be made to automatically delete the temporary file when the processor terminates the pipeline. No error will be raised if this is unsuccessful.

If the temporary file creation is successful, the step returns a c:result element containing the absolute URI of this 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:

Document properties

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