collmgr-005

Tests that cx:collection-manager collections are visible in XSLT.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
   <p:import href="https://xmlcalabash.com/ext/library/collection-manager.xpl"/>
   <p:output port="result"/>
   <cx:collection-manager name="coll"
                          source="http://example.com/c1" stable="false">
      <p:with-input>
         <p:inline document-properties="map {'base-uri': 'http://example.com/c1'}">
            <doc/>
         </p:inline>
         <p:inline document-properties="map {'base-uri': 'http://example.com/c2'}">
            <doc/>
         </p:inline>
      </p:with-input>
   </cx:collection-manager>
   <p:xslt template-name="main" depends="coll">
      <p:with-input port="source">
         <p:empty/>
      </p:with-input>
      <p:with-input port="stylesheet">
         <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                         version="3.0">
            <xsl:template name="main">
               <count>
                  <xsl:value-of select="count(collection('http://example.com/c1'))"/>
               </count>
            </xsl:template>
         </xsl:stylesheet>
      </p:with-input>
   </p:xslt>
</p:declare-step>

Result

<count xmlns:cx="http://xmlcalabash.com/ns/extensions"
       xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:t="http://xproc.org/ns/testsuite/3.0">2</count>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="count">The document root is not correct.</s:assert>
         <s:assert test="count = 2">The number of documents is not correct.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

23 Jan 2025, Norm Tovey-Walsh
Created test.