<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/trang-009.xml"
        name="trang-009.xml"
        expected="pass">
   <t:info>
      <t:title>trang-009</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>Tests RNC to DTD</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="dtd">
            <p:with-input expand-text="false">
               <p:inline content-type="application/relax-ng-compact-syntax">
doc = element doc { attlist.doc, p+ }
attlist.doc &amp;= empty
p = element p { attlist.p, text* }
attlist.p &amp;= empty
start = doc
      </p:inline>
            </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="contains(., '&lt;!ELEMENT')">Output isn’t a DTD.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="trang-009.xml">
      <wrapper>&lt;?xml encoding="UTF-8"?&gt;

&lt;!ELEMENT doc (p)+&gt;

&lt;!ELEMENT p (#PCDATA)*&gt;
</wrapper>
   </t:result>
</t:test>
