<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
  <t:info>
    <t:title>java-properties-009</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2025-01-20</t:date>
        <t:author>
          <t:name>Norm Tovey-Walsh</t:name>
        </t:author>
        <t:description xmlns="http://www.w3.org/1999/xhtml">
          <p>Created test.</p>
        </t:description>
      </t:revision>
    </t:revision-history>
  </t:info>
  <t:description xmlns="http://www.w3.org/1999/xhtml">
    <p>Tests that a map can be cast to Java properties.</p>
  </t:description>
<t:pipeline>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:ex="https://xmlcalabash.com/ns/examples"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:cx="http://xmlcalabash.com/ns/extensions"
                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>
</t:pipeline>
  <t:schematron>
    <s:schema queryBinding="xslt2"
              xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <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(., '&#13;', ''), 'first=One&#10;')">first is missing.</s:assert>
          <s:assert test="contains(replace(., '&#13;', ''), 'second=Two&#10;')">second is missing.</s:assert>
          <s:assert test="contains(replace(., '&#13;', ''), 'third=&#10;')">third is missing.</s:assert>
          <s:assert test="contains(replace(., '&#13;', ''), 'fourth=3.14&#10;')">fourth is missing.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
