nw-os-exec-002
Tests p:os-exec when the output encoding doesn’t match Java’s encoding.
The test assumes that your Java encoding isn’t ISO Latin 1. That seems…reasonable,
but not infallible.
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', '-encoding:iso-8859-1', '-stderr:false', '-text:«Hello, world»©')"/>
</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, world??
</c:stdout>
<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, world')">Stdout is incorrect.</s:assert>
<s:assert test="not(contains(c:stdout, '«'))">Encoding is unexpected.</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.