<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="trang-015.xml"
        name="trang-015.xml"
        expected="pass">
   <t:info>
      <t:title>trang-015</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-03-23</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>Multipart RNC to RNG</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">
         <p:import href="https://xmlcalabash.com/ext/library/trang.xpl"/>
         <p:output port="result" sequence="true"/>
         <cx:trang output-base-uri="http://example.com/schemas/" result-format="rng">
            <p:with-input>
               <p:document href="../documents/rnc/schema.rnc"/>
               <p:document href="../documents/rnc/core.rnc"/>
               <p:document href="../documents/rnc/sub/b.rnc"/>
            </p:with-input>
         </cx:trang>
         <p:wrap-sequence wrapper="wrapper"/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="rng" uri="http://relaxng.org/ns/structure/1.0"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="wrapper">The root is wrong.</s:assert>
               <s:assert test="count(wrapper/rng:grammar) = 3">Wrong number of schemas.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="trang-015.xml">
      <wrapper>
         <grammar xmlns="http://relaxng.org/ns/structure/1.0"
                  xmlns:ex="http://example.com/ns"
                  ns="http://example.com/ns">
            <define name="a">
               <element name="ex:a">
                  <empty/>
               </element>
            </define>
            <include href="b.rng"/>
         </grammar>
         <grammar xmlns="http://relaxng.org/ns/structure/1.0"
                  xmlns:ex="http://example.com/ns"
                  ns="http://example.com/ns">
            <start>
               <ref name="ex.first"/>
            </start>
            <define name="ex.first">
               <element name="ex:first">
                  <ref name="a"/>
                  <ref name="b"/>
               </element>
            </define>
            <include href="core.rng"/>
         </grammar>
         <grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:ex="http://example.com/ns">
            <define name="b">
               <element name="ex:b">
                  <empty/>
               </element>
            </define>
         </grammar>
      </wrapper>
   </t:result>
</t:test>
