Re: using XProc and Calabash to process multiple files

Hi Robert,

I'm only an amateur xproctologist myself. Perhaps an actual expert will
chime in with better advice, but here are my thoughts:

I never had any luck getting the calabash ant task to work. When I
invoke calabash from ant, I just use the <java> task. Since I've never
used the calabash task, I don't know how it is designed to work when
given a set of files. Will it really run each one through the pipeline?
Does your code work if there is only one file in that directory? Like I
said, I've never gotten that task to work so I can't say.

If I were doing this, I would put everything in XProc. In this case, I
might use the xpath collection() function inside the pipeline to find
all the files in the target directory, then use p:for-each with
p:iteration-source to loop over the result and operate on each file,
using p:store to store the result. In this case, the input and output of
the pipeline would be irrelevant. If you use Ant at all, it would just
be as a wrapper from which to call Calabash.

Regards,

David

On 5/15/20 5:02 PM, Robert Stuart wrote:
> My final goal is to process many Docbook instances and produce the FO using the Docbook XSL 2 Stylesheets.  My simple stepping stone that does not work was to run the identity Xproc step on multiple files.
> It appears to run until right after it hits the last file in the first directory child of examples. I get output files to out corresponding to the input files. BUT I then get the following error and it chokes. If some kind soul would point me in the right direction I would really appreciate it. If for some reason extending this simple yet not yet working example to the pipeline docbook-xslt2-2.6.0/xslt/base/pipelines/db2fo.xpl will not work for some reason help there would be appreciated.
>
> Environment info:
> xmlcalabash-1.2.1-99.jar
> OS X 10.14.6
> java Corretto-8.232.09.2
> saxon SaxonHE9-9-1-7J
>
>
> build.xml:58: com.xmlcalabash.core.XProcException: Duplicate output binding for default output port.
>  at com.xmlcalabash.util.UserArgs.addOutput(UserArgs.java:271)
>  at com.xmlcalabash.drivers.CalabashTask.process(CalabashTask.java:1285)
>  at com.xmlcalabash.drivers.CalabashTask.execute(CalabashTask.java:1201)
>  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  at java.lang.reflect.Method.invoke(Method.java:498)
>  at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
>  at org.apache.tools.ant.Task.perform(Task.java:350)
>  at org.apache.tools.ant.Target.execute(Target.java:449)
>  at org.apache.tools.ant.Target.performTasks(Target.java:470)
>  at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
>  at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
>  at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>  at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
>  at org.apache.tools.ant.Main.runBuild(Main.java:834)
>  at org.apache.tools.ant.Main.startAnt(Main.java:223)
>  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
>  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
>
> Total time: 11 seconds
>
> <?xml version="1.0" encoding="UTF-8"?>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
>   xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
>   <p:input port="source"/>
>   <p:output port="result"/>
>   <p:identity/>
> </p:declare-step>
>
> Using an ant task
>
>   <target name="test2Calabash">
>       <calabash  includes="**/*.xml"
>           basedir="${examples.dir}/"
>           destdir="${generatedReports.dir}/out">
>           <pipeline>
>               <file file="${basedir}/XPROC/identity.xpl" />
>           </pipeline>
>       </calabash>
>   </target>
>
> Note for ant I did end up having to add a taskdef  since only adding typedef didn’t seem to do it for me.
>
> <taskdef resource="com/xmlcalabash/antlib.xml">
>       <classpath>
>           <pathelement location="${deps.static}/xmlcalabash-1.2.1-99/xmlcalabash-1.2.1-99.jar"/>
>       </classpath>
>   </taskdef>
>

Received on Monday, 18 May 2020 20:53:59 UTC