java-properties-007

Tests that a Java properties file can be cast to YAML (same as JSON).

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="application/x-yaml">
      <p:with-input>
         <p:inline content-type="text/x-java-properties"># With a comment.
version=1.0
name=TestApp
date=2016-11-12</p:inline>
      </p:with-input>
   </p:cast-content-type>
   <p:cast-content-type content-type="application/xml"/>
</p:declare-step>

Result

<map xmlns="http://www.w3.org/2005/xpath-functions"
     xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <string key="name">TestApp</string>
   <string key="date">2016-11-12</string>
   <string key="version">1.0</string>
</map>

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="fn"
         uri="http://www.w3.org/2005/xpath-functions"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="fn:map">The document root is not correct.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/fn:map">
         <s:assert test="count(fn:string) = 3">Wrong number of entries.</s:assert>
         <s:assert test="fn:string[@key='version'] = '1.0'">Version is wrong.</s:assert>
         <s:assert test="fn:string[@key='name'] = 'TestApp'">Name is wrong.</s:assert>
         <s:assert test="fn:string[@key='date'] = '2016-11-12'">Date is wrong.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

20 Jan 2025, Norm Tovey-Walsh
Created test.