trang-012

Multipart DTD to RNG

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" 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/dtd/schema.dtd"/>
         <p:document href="../documents/dtd/core.dtd"/>
         <p:document href="../documents/dtd/sub/b.dtd"/>
      </p:with-input>
   </cx:trang>
   <p:wrap-sequence wrapper="wrapper"/>
</p:declare-step>

Result

<wrapper xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <grammar xmlns="http://relaxng.org/ns/structure/1.0"
            xmlns:ex="http://example.com/ns">
      <define name="a">
         <element name="ex:a">
            <ref name="attlist.a"/>
            <empty/>
         </element>
      </define>
      <define name="attlist.a" combine="interleave">
         <empty/>
      </define>
      <include href="b.rng"/>
   </grammar>
   <grammar xmlns="http://relaxng.org/ns/structure/1.0"
            xmlns:ex="http://example.com/ns">
      <define name="first">
         <element name="ex:first">
            <ref name="attlist.first"/>
            <ref name="a"/>
            <ref name="b"/>
         </element>
      </define>
      <define name="attlist.first" combine="interleave">
         <empty/>
      </define>
      <include href="core.rng"/>
      <start>
         <choice>
            <ref name="first"/>
         </choice>
      </start>
   </grammar>
   <grammar xmlns="http://relaxng.org/ns/structure/1.0"
            xmlns:ex="http://example.com/ns">
      <define name="b">
         <element name="ex:b">
            <ref name="attlist.b"/>
            <empty/>
         </element>
      </define>
      <define name="attlist.b" combine="interleave">
         <empty/>
      </define>
   </grammar>
</wrapper>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" 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>

Revision history

23 Mar 2025, Norm Tovey-Walsh
Created test.