java-properties-008

Tests that XML can be cast to Java properties.

Test java-properties-008.xml 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: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>

Schematron validation

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" 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(., '&#xD;', ''), '&#xA;first=One&#xA;')">first is missing.</s:assert>
         <s:assert test="contains(replace(., '&#xD;', ''), '&#xA;second=Two&#xA;')">second is missing.</s:assert>
         <s:assert test="contains(replace(., '&#xD;', ''), '&#xA;three=\u201CSeveral\u201D\nlines\u203D&#xA;')">third is missing.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

20 Jan 2025, Norm Tovey-Walsh

Created test.