java-properties-009

Tests that a map 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 expand-text="false">
         <p:inline content-type="application/json">
        { "first": "One",
          "second": "Two",
          "third": null,
          "fourth": 3.14 }</p:inline>
      </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">first=One
fourth=3.14
second=Two
third=

</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(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(., '
', ''), 'third=
')">third is missing.</s:assert>
         <s:assert test="contains(replace(., '
', ''), 'fourth=3.14
')">fourth is missing.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

20 Jan 2025, Norm Tovey-Walsh
Created test.