W3C home > Mailing lists > Public > xproc-dev@w3.org > February 2013

RE: Problems when copying files

From: Geert Josten <geert.josten@dayon.nl>
Date: Tue, 26 Feb 2013 13:02:57 +0100
Message-ID: <69b56918d04d016bb04ed02e049fa43c@mail.gmail.com>
To: Jostein Austvik Jacobsen <josteinaj@gmail.com>, George Cristian Bina <george@oxygenxml.com>
Cc: xproc-dev@w3.org
Sounds somewhat related to the ‘Multiple XSLT transformations with
intermediate files’ thread..



Grtz



*Van:* Jostein Austvik Jacobsen [mailto:josteinaj@gmail.com]
*Verzonden:* dinsdag 26 februari 2013 9:58
*Aan:* George Cristian Bina
*CC:* xproc-dev@w3.org
*Onderwerp:* Re: Problems when copying files



It doesn't seem like the spec specifies whether an implementation should
creating any missing parent directories[1] so I don't know what is to be
expected. Maybe something like <p:store mkdirs="true|false" .../> could be
useful?



Since there's no "top-to-bottom" execution order in XProc, you're not
guaranteed that the copy operation from xml/ to xml1/ is completed before
the copy operation from xml1/ to xml2/.



AFAIK there's no multi-threading in calabash yet so the execution order for
a script when running it through calabash is the same every time if you run
it, and usually it executes bottom to top (it seems). So in your script,
all files from xml1/ will be copied to xml2/ *before* the files in xml/ is
copied to xml1/, which means there will be no files copied from xml1/ to
xml2/ at first run.



To make sure that you only load a file *after* the file is stored, you can
force a dependency between two steps by connecting it to a port or option
on the step that has a dependency:

<p:store href="test.xml" name="store1"/>

<p:load>

    <p:with-option name="href" select="'test.xml'">

        <p:pipe step="store1" port="result"/>

    </p:with-option>

</p:load>



Calabash also has the cx:depends-on="step-name" attribute to simplify
things:

<p:store href="test.xml" name="store1"/>

<p:load href="test.xml" cx:depends-on="store1"/>



[1] http://www.w3.org/TR/xproc/#c.store



Jostein



On 26 February 2013 08:59, George Cristian Bina <george@oxygenxml.com>
wrote:

Hi all,

Any feedback on the issue below?



Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 2/15/13 11:45 AM, George Cristian Bina wrote:

Hi,

We obtain some strange results with the following script with Calabash
1.0.8 (I think I encountered this also on previous versions).

We have the following structure:

./xml/test.xml
./test.xpl

See the files content below [1].

The test.xpl script should load the files from the xml folder and then
store them in a folder called xml1, then load the files from the folder
xml1 and store them in a folder xml2.

Trying to run the script gives the following error:
Scenario: test
XProc file: /Users/george/Documents/test/xproc_samples/test.xpl
Engine name: Calabash XProc
Severity: error
Description: err:XC0017 : XC0017 It is a dynamic error if the absolute
path does not identify a directory.

I then created an xml1 folder so we have now the following structure

./xml/test.xml
./xml1/
./test.xpl

First run does not give any error but the result structure is

./xml/test.xml
./xml1/test.xml
./test.xpl

That is the file was copied to xml1 but no copy from xml1 to xml2 took
place.
Running again the script with the new structure gives the desired result

./xml/test.xml
./xml1/test.xml
./xml2/test.xml
./test.xpl

Is this the expected behavior?

[1] sample files

test.xml
========
<test/>

test.xpl
========
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
name="sampleCopyTest" version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:c="http://www.w3.org/ns/xproc-step">

   <p:input port="source" sequence="true"/>
   <p:output port="result" sequence="true">
     <p:empty/>
   </p:output>

   <p:variable name="input" select="'xml/'"/>
   <p:variable name="out1" select="'xml1/'"/>
   <p:variable name="out2" select="'xml2/'"/>

   <p:directory-list>
     <p:with-option name="path" select="$input"/>
   </p:directory-list>

   <p:for-each>
     <p:iteration-source select="/c:directory/c:file"/>
     <p:variable name="filename" select="/c:file/@name"/>
     <p:variable name="result" select="concat($out1, $filename)"/>

     <p:load>
       <p:with-option name="href" select="concat($input, $filename)"/>
     </p:load>
     <p:store omit-xml-declaration="false">
       <p:with-option name="href" select="$result"/>
     </p:store>

   </p:for-each>

   <p:directory-list>
     <p:with-option name="path" select="$out1"/>
   </p:directory-list>

   <p:for-each>
     <p:iteration-source select="/c:directory/c:file"/>
     <p:variable name="filename" select="/c:file/@name"/>
     <p:variable name="result" select="concat($out2, $filename)"/>
     <p:load>
       <p:with-option name="href" select="concat($out1, $filename)"/>
     </p:load>
     <p:store omit-xml-declaration="false">
       <p:with-option name="href" select="$result"/>
     </p:store>
   </p:for-each>

</p:declare-step>
Received on Tuesday, 26 February 2013 12:03:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 26 February 2013 12:03:27 GMT