W3C home > Mailing lists > Public > public-xml-processing-model-comments@w3.org > September 2007

Re: file operations and XProc

From: Vasil Rangelov <boen.robot@gmail.com>
Date: Thu, 13 Sep 2007 11:15:47 +0300
To: <public-xml-processing-model-comments@w3.org>
Message-ID: <46e8f1ce.2215300a.31e7.ffffea14@mx.google.com>

>One of the only weaknesses of XProc (as I can see it), is the lack of
>any kind of file operation management.
>
>Standard file operations are;
>
>    * copy
>    * move
>    * delete
>    * which file is more up to date (compare file metadata)
>    * change file encoding (this is a biggie no?)
>    * chown/chmod
>
>I can envisage an XProc step called  p:file-operation.

If dealing with XML files, you could sort of use p:store for copying and
p:sink for deleting (provided the WG clears up what "discards" means). The
combination of the two could be used for moving. Encoding could probably be
changeable if reserializing the document with a new encoding using p:store.

And yes, the rest aren't doable currently.

I agree that even with the mentioned workarounds above, it would be good to
add file and directory operations like those for two reasons:
1. They will work on all files.
2. File operations will be done faster on XML with such steps then with
those workarounds since the document won't have to be parsed.

However, I don't think a single step for it all is a good idea. File
operations are too different to combine in a single step. It will make much
clutter. Perhaps a set of p:directory-* and p:file-* steps would do best.

To be more precise, I propose the following definitions:
<p:declare-step type="p:file-copy">
	<p:output port="result"/><!-- Returns a c:result element having
"file" and "location" with their respective values, or error if unable to
copy -->
	<p:option name="file"/><!-- The file to copy -->
	<p:option name="location"/><!-- The location and name of the new
file -->
</p:declare-step>

<p:declare-step type="p:directory-copy">
	<p:output port="result"/><!-- Returns a c:result element having
"file" and "location" with their respective values, or error if unable to
copy -->
	<p:option name="directory"/><!-- The directory (and all of its
contents) to copy -->
	<p:option name="location"/><!-- The location and name of the new
directory -->
</p:declare-step>

<p:declare-step type="p:file-delete">
	<p:option name="file"/><!-- The file to delete. -->
</p:declare-step>

<p:declare-step type="p:directory-delete">
	<p:option name="directory"/><!-- The directory to delete. Before you
suggest that this is combined with p:fil-->
</p:declare-step>

<p:declare-step type="p:file-recode">
	<p:output port="result"/><!-- Returns a c:result element having
"file" and "location" with their respective values, or error if unable to
recode-->
	<p:option name="file"/><!-- The file to recode -->
	<p:option name="encoding"/><!-- The new encoding of the file.
Implementations should automatically detect the current encoding.-->
	<p:option name="location"/><!-- The location for a new file using
the specified encoding -->
</p:declare-step>

<p:declare-step type="p:get-file-information">
	<p:output port="result"/><!-- Returns a c:result element having
"file" and "information" with their respective values and the result of the
query as contents of c:result, or error if unable to get the information-->
	<p:option name="file"/><!-- The file to get meta data from -->
	<p:option name="information"/><!-- The exact information to query
for. Possible values may include "creation-timestamp",
"last-modificaiton-timestamp","is-read-only" and more -->
</p:declare-step>

<p:declare-step type="p:get-directory-information">
	<p:output port="result"/><!-- Returns a c:result element having
"file" and "information" with their respective values and the result of the
query as contents of c:result, or error if unable to get the information-->
	<p:option name="directory"/><!-- The directory to get meta data from
-->
	<p:option name="information"/><!-- The exact information to query
for. Possible values may include "creation-timestamp",
"last-modificaiton-timestamp","read-only" and more -->
</p:declare-step>

<p:declare-step type="p:set-file-information">
	<p:output port="result"/><!-- Returns a c:result element having
"file" and "information" with their respective values and new value as
contents of c:result, or error if unable to get or set the information-->
	<p:option name="file"/><!-- The file to get meta data from -->
	<p:option name="information"/><!-- The exact information to query
for. Possible values may include "creation-timestamp",
"last-modificaiton-timestamp","is-read-only" and more -->
</p:declare-step>

<p:declare-step type="p:set-directory-information">
	<p:output port="result"/><!-- Returns a c:result element having
"file" and "information" with their respective values and new value as
contents of c:result, or error if unable to get or set the information-->
	<p:option name="directory"/><!-- The directory to get meta data from
-->
	<p:option name="information"/><!-- The exact information to query
for. Possible values may include "creation-timestamp",
"last-modificaiton-timestamp","read-only" and more -->
	<p:option name="new-value"/><!-- The new value of this information
-->
</p:declare-step>

I'm not sure if there's a point of creating p:file-move and p:directory-move
with p:*-delete in place, but if they are created, their signatures should
probably be as p:*-copy.

Regards,
Vasil Rangelov
Received on Thursday, 13 September 2007 08:16:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:21:42 GMT