<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="rdf-trig-003.xml"
        name="rdf-trig-003.xml"
        expected="pass">
   <t:info>
      <t:title>rdf-trig-003</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 application/trig can be queried.</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 content-type="application/trig" href="../documents/sample1.trig"/>
         <cx:sparql>
            <p:with-input port="query">
               <p:document content-type="application/sparql-query" href="../documents/query1.rq"/>
            </p:with-input>
         </cx:sparql>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="sr" uri="http://www.w3.org/2005/sparql-results#"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="sr:sparql">The root is wrong.</s:assert>
            </s:rule>
            <s:rule context="/sr:sparql">
               <s:assert test="sr:head">There’s no head</s:assert>
               <s:assert test="sr:results">There are no results</s:assert>
            </s:rule>
            <s:rule context="/sr:sparql/sr:head">
               <s:assert test="count(sr:variable) = 2">Wrong number of headers</s:assert>
            </s:rule>
            <s:rule context="/sr:sparql/sr:results">
               <s:assert test="count(sr:result) = 3">Wrong number of results</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="rdf-trig-003.xml">
      <sparql xmlns="http://www.w3.org/2005/sparql-results#">
         <head>
            <variable name="document"/>
            <variable name="title"/>
         </head>
         <results>
            <result>
               <binding name="document">
                  <uri>https://xproc.org/</uri>
               </binding>
               <binding name="title">
                  <literal datatype="http://www.w3.org/2001/XMLSchema#string">XProc</literal>
               </binding>
            </result>
            <result>
               <binding name="document">
                  <uri>https://spec.xproc.org/3.0/xproc/</uri>
               </binding>
               <binding name="title">
                  <literal datatype="http://www.w3.org/2001/XMLSchema#string">XProc 3.0: An XML Pipeline Language</literal>
               </binding>
            </result>
            <result>
               <binding name="document">
                  <uri>https://spec.xproc.org/3.0/steps/</uri>
               </binding>
               <binding name="title">
                  <literal datatype="http://www.w3.org/2001/XMLSchema#string">XProc 3.0: Standard Step Library</literal>
               </binding>
            </result>
         </results>
      </sparql>
   </t:result>
</t:test>
