Features: os-exec

nw-os-exec-001

Tests p:os-exec using stdmsgs.jar

Test is expected to pass.

The pipeline

<p:declare-step xmlns:c="http://www.w3.org/ns/xproc-step"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
   <p:output port="result"/>
   <p:os-exec name="exec" command="java">
      <p:with-input>
         <p:empty/>
      </p:with-input>
      <p:with-option name="args"
                     select="('-cp', resolve-uri('../lib/stdmsgs.jar', static-base-uri()),                                  'com.nwalsh.StandardMessages')"/>
   </p:os-exec>
   <p:wrap-sequence name="stdout" wrapper="c:stdout"/>
   <p:wrap-sequence name="stderr" wrapper="c:stderr">
      <p:with-input pipe="error@exec"/>
   </p:wrap-sequence>
   <p:wrap-sequence wrapper="c:result">
      <p:with-input pipe="@stdout @stderr exit-status@exec"/>
   </p:wrap-sequence>
</p:declare-step>

Result

<c:result xmlns:c="http://www.w3.org/ns/xproc-step"
          xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <c:stdout>Hello from stdout.
</c:stdout>
   <c:stderr>Hello from stderr.
</c:stderr>
   <c:result>0</c:result>
</c:result>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:ns prefix="c"
         uri="http://www.w3.org/ns/xproc-step"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="c:result">The document root is not 'c:result'.</s:assert>
      </s:rule>
      <s:rule context="/c:result">
         <s:assert test="contains(c:stdout, 'Hello from stdout')">Stdout is incorrect.</s:assert>
         <s:assert test="contains(c:stderr, 'Hello from stderr')">Stderr is incorrect.</s:assert>
         <s:assert test="c:result = '0'">Return code is incorrect.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

02 May 2025, Norm Tovey-Walsh
Initial commit.