trang-010

Tests RNC to XSD

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="xsd">
      <p:with-input expand-text="false">
         <p:inline content-type="application/relax-ng-compact-syntax">
doc = element doc { attlist.doc, p+ }
attlist.doc &= empty
p = element p { attlist.p, text* }
attlist.p &= empty
start = doc
      </p:inline>
      </p:with-input>
   </cx:trang>
</p:declare-step>

Result

<xs:schema xmlns:t="http://xproc.org/ns/testsuite/3.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
   <xs:element name="doc">
      <xs:complexType>
         <xs:sequence>
            <xs:element maxOccurs="unbounded" ref="p"/>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <xs:element name="p" type="xs:string"/>
</xs:schema>

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:ns prefix="xs"
         uri="http://www.w3.org/2001/XMLSchema"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="xs:schema">The root is wrong.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

23 Mar 2025, Norm Tovey-Walsh
Created test.