Re: File utilities on exproc.org

Norman Walsh <ndw@nwalsh.com> writes:
[...]
> It's an interesting idea...

Here's a sketch of a fileutils library that assumes most of the steps
are the identity transform with <c:result>/<c:error> status reports
appearing on a secondary status port.

I'm still leaving fail-on-error in place because the overhead of
try/catch for mkdir on a directory that exists or delete on a file
that doesn't seems onerous. (Maybe that says more about the verbosity
of our try/catch mechanism, but...)

<p:library xmlns:p="http://www.w3.org/ns/xproc"
           xmlns:cx="http://xmlcalabash.com/ns/extensions"
           xmlns:cxf="http://xmlcalabash.com/ns/extensions/fileutils"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           version="1.0">

<p:declare-step type="cxf:copy">
   <p:input port="source"/>
   <p:output port="result" primary="true"/>
   <p:output port="status"/>
   <p:option name="href" required="true"/>
   <p:option name="target" required="true"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

<p:declare-step type="cxf:delete">
   <p:input port="source"/>
   <p:output port="result" primary="true"/>
   <p:output port="status"/>
   <p:option name="href" required="true"/>
   <p:option name="recursive" select="'false'"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

<!-- Send the info to a secondary status port, or leave the output primary? -->
<p:declare-step type="cxf:head">
   <p:output port="result"/>
   <p:option name="href" required="true"/>
   <p:option name="count" required="true"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

<!-- Send the info to a secondary status port, or leave the output primary? -->
<p:declare-step type="cxf:info">
   <p:output port="result" sequence="true"/>
   <p:option name="href" required="true"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

<p:declare-step type="cxf:mkdir">
   <p:input port="source"/>
   <p:output port="result" primary="true"/>
   <p:output port="status"/>
   <p:option name="href" required="true"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

<p:declare-step type="cxf:move">
   <p:input port="source"/>
   <p:output port="result" primary="true"/>
   <p:output port="status"/>
   <p:option name="href" required="true"/>
   <p:option name="target" required="true"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

<!-- Send the info to a secondary status port, or leave the output primary? -->
<p:declare-step type="cxf:tail">
   <p:output port="result"/>
   <p:option name="href" required="true"/>
   <p:option name="count" required="true"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

<p:declare-step type="cxf:tempfile">
   <p:input port="source"/>
   <p:output port="result" primary="true"/>
   <p:output port="status"/>
   <p:option name="href" required="true"/>
   <p:option name="prefix"/>
   <p:option name="suffix"/>
   <p:option name="delete-on-exit"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

<p:declare-step type="cxf:touch">
   <p:input port="source"/>
   <p:output port="result" primary="true"/>
   <p:output port="status"/>
   <p:option name="href" required="true"/>
   <p:option name="timestamp"/>
   <p:option name="fail-on-error" select="'true'"/>
</p:declare-step>

</p:library>

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
Lead Engineer
MarkLogic Corporation
Phone: +1 512 761 6676
www.marklogic.com

Received on Wednesday, 27 March 2013 12:51:53 UTC