rdf-srx-002

Tests that cx:sparql can produce application/sparql-results+xml.

Test rdf-srx-002.xml is expected to pass.

The 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"/>
   <cx:sparql content-type="application/sparql-results+xml">
      <p:with-input port="source" href="../documents/address-book.rdf"/>
      <p:with-input port="query" href="../documents/query2.rq"/>
   </cx:sparql>
</p:declare-step>

Schematron validation

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:ns prefix="r" uri="http://www.w3.org/2005/sparql-results#"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="r:sparql">The root is not r:sparql.</s:assert>
         <s:assert test="r:sparql/r:head">There is no r:head</s:assert>
         <s:assert test="r:sparql/r:results">There is no r:results</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/r:sparql/r:head">
         <s:assert test="count(r:variable) = 3">Wrong number of columns</s:assert>
         <s:assert test="r:variable[@name = 'category']">No category.</s:assert>
         <s:assert test="r:variable[@name = 'name']">No name.</s:assert>
         <s:assert test="r:variable[@name = 'locality']">No locality.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/r:sparql/r:results">
         <s:assert test="count(r:result) = 13">Wrong number of results: <s:value-of select="count(r:result)"/>
         </s:assert>
         <s:assert test="r:result/r:binding[@name='name']/r:literal = 'Patina'">One of the expected results is missing.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

15 Feb 2025, Norm Tovey-Walsh

Created test.