<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/rdf-srj-001.xml"
        name="rdf-srj-001.xml"
        expected="pass">
   <t:info>
      <t:title>rdf-srj-001</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-02-15</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 .srj loads as application/sparql-results+json and JSON.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      name="main"
                      version="3.0"
                      expand-text="false">
         <p:import href="https://xmlcalabash.com/ext/library/rdf.xpl"/>
         <p:output port="result"/>
         <p:load name="load" href="../documents/results1.srj"/>
         <p:identity>
            <p:with-input select=". instance of map(*)"/>
         </p:identity>
         <p:cast-content-type content-type="text/plain"/>
         <p:wrap-sequence name="first" wrapper="type"/>
         <p:identity>
            <p:with-input select="p:document-properties(.)" pipe="@load"/>
         </p:identity>
         <p:cast-content-type name="second" content-type="application/xml"/>
         <p:wrap-sequence wrapper="wrapper">
            <p:with-input pipe="@first @second"/>
         </p:wrap-sequence>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="rdf" uri="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
         <s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="wrapper">The root is not wrapper.</s:assert>
               <s:assert test="wrapper/type">The type is missing.</s:assert>
               <s:assert test="wrapper/type = 'true'">The type isn’t true.</s:assert>
               <s:assert test="wrapper/fn:map">The properties map is missing.</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/wrapper/fn:map">
               <s:assert test="fn:string[@key='content-type'] = 'application/sparql-results+json'">The result content-type is incorrect.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="rdf-srj-001.xml">
      <wrapper>
         <type>true</type>
         <map xmlns="http://www.w3.org/2005/xpath-functions">
            <string key="base-uri">file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/documents/results1.srj</string>
            <string key="content-type">application/sparql-results+json</string>
         </map>
      </wrapper>
   </t:result>
</t:test>
