I have a XProc pipeline that loops over several files.
The problem I encountered is that on some files errors were thrown,
but it was very hard to decipher which file(s) the errors were related to.
This is what appeared on the console:
I don't know how to handle this kind of element declaration yet. (foo)
I don't know how to handle this kind of element declaration yet. (foo)
I don't know how to handle this kind of element declaration yet. (foo)
...
What I wanted to achieve was to send at the start of every loop a message to the console with the name of the file used.
However I couldn't find such a functionality within the steps defined by the XProc spec.
Luckily both available xproc processors
Norm Walsh's
Calabash and EMC's
Calumet offer an extension step precisely for this aim.
In the case of
Calabash it is:
cx:message
<p:declare-step type="cx:message">
<p:input port="source"/>
<p:output port="result"/>
<p:option name="message" required="true"/> <!-- string -->
</p:declare-step>
In the case of
Calumet:
x:message
<p:declare-step type="x:message">
<p:option name="message" required="true"/><!-- string -->
<p:option name="stderr" select="'true'"/><!-- true/false -->
<p:option name="stdout" select="'false'"/><!-- true/false -->
<p:input port="source" sequence="true"/>
<p:output port="result" sequence="true"/>
</p:declare-step>
using Calabash
What needs to be done using Calabash to get the use of it.
- first import the relevant pipeline library at: http://xmlcalabash.com/extension/steps/library-1.0.xpl.
<p:import href="http://xmlcalabash.com/extension/steps/library-1.0.xpl"/>
- make sure the respective namespace is declared
xmlns:cx="http://xmlcalabash.com/ns/extensions"
- place the cx:message step within your logic
<p:for-each name="fileloop">
<p:output port="result" sequence="true">
</p:output>
<p:iteration-source select="/c:directory/c:file"/>
<p:variable name="file" select="/c:file/@name"/>
<p:load name="schema">
<p:with-option name="href" select="$file"/>
</p:load>
<cx:message>
<p:with-option name="message" select="$file"/>
</cx:message>
....
</p:for-each>
Without the cx:message we had:
I don't know how to handle this kind of element declaration yet. (foo)
I don't know how to handle this kind of element declaration yet. (foo)
I don't know how to handle this kind of element declaration yet. (foo)
With cx:message we get:
Message: file:/Users/paul/Desktop/R&D/xmlschema/msData/particles/particlesC040.xsd
I don't know how to handle this kind of element declaration yet. (foo)
Message: file:/Users/paul/Desktop/R&D/xmlschema/msData/particles/particlesC041.xsd
I don't know how to handle this kind of element declaration yet. (foo)
Message: file:/Users/paul/Desktop/R&D/xmlschema/msData/particles/particlesC042.xsd
I don't know how to handle this kind of element declaration yet. (foo)
Comments