java-properties-008
Tests that XML can be cast to Java properties.
Test is expected to pass.
The pipeline
<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:ex="https://xmlcalabash.com/ns/examples" xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-inline-prefixes="ex xs cx"
name="main" version="3.0">
<p:output port="result"/>
<p:cast-content-type content-type="text/x-java-properties">
<p:with-input>
<properties>
<comment> Hello, world.</comment>
<entry key="first">One</entry>
<entry key="second">One</entry>
<entry key="second">Two</entry>
<entry key="three">“Several”
lines‽</entry>
</properties>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="props"/>
</p:declare-step>
Result
<props xmlns:t="http://xproc.org/ns/testsuite/3.0"># Hello, world.
first=One
second=Two
three=\u201CSeveral\u201D\nlines\u203D
</props>
Schematron checks
<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
<s:pattern>
<s:rule context="/">
<s:assert test="props">The document root is not correct.</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="/props">
<s:assert test="contains(., '# Hello, world')">Comment is missing.</s:assert>
<s:assert test="contains(replace(., '
', ''), '
first=One
')">first is missing.</s:assert>
<s:assert test="contains(replace(., '
', ''), '
second=Two
')">second is missing.</s:assert>
<s:assert test="contains(replace(., '
', ''), '
three=\u201CSeveral\u201D\nlines\u203D
')">third is missing.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 20 Jan 2025, Norm Tovey-Walsh
- Created test.