RELAX NG Schema for Lists
Author: Hugh Field-Richards
Date: 2004-10-28T08:30

This is the RELAX NG schema for lists.


Included file: common.rng

Lists

A list can contain a huge number of types of items. DSD-2 does this quite happily in one rule statement without using Schematron ... sigh ;-)

list.listElement — Warning! not used within this schema file.
define : list.listElement
element : list
Schematron
Check for title present in descriptive lists
Context : “//list:list[@type='descriptive']
if not condition “list:item/list:title
then output: There must be an item title element for descriptive lists
refcommon.commonAttributes
optional
attribute : item-label
zeroOrMore
<define name="list.listElement">
   <element name="list">
      <sch:pattern name="Check for title present in descriptive lists" id="Lists">
         <sch:rule context="//list:list[@type='descriptive']">
            <sch:assert test="list:item/list:title">There must be an item title element for descriptive lists</sch:assert>
         </sch:rule>
      </sch:pattern>
      <ref name="common.commonAttributes"/>
      <ref name="list.listTypeAttribute"/>
      <optional>
         <attribute name="item-label"/>
      </optional>
      <zeroOrMore>
         <ref name="list.listItemElement"/>
      </zeroOrMore>
   </element>
</define>

Determines the type of the list.

list.listTypeAttribute (Combine: choice)
define : list.listTypeAttribute
optional
attribute : type
choice
value = "ordered"
value = "unordered"
value = "numbered"
value = "descriptive"
<define name="list.listTypeAttribute" combine="choice">
   <optional>
      <attribute name="type">
         <choice>
            <value>ordered</value>
            <value>unordered</value>
            <value>numbered</value>
            <value>descriptive</value>
         </choice>
      </attribute>
   </optional>
</define>

List Item

We may be able to restrict what goes in list items by invoking the Schematron. This will need investigating.

define : list.listItemElement
element : item
refcommon.commonAttributes
optional
optional
attribute : item-label
zeroOrMore
interleave
choice
reftext.verticalContent
reftext.horizontalContent
Any text
<define name="list.listItemElement">
   <element name="item">
      <ref name="common.commonAttributes"/>
      <optional>
         <ref name="list.itemTitleElement"/>
      </optional>
      <ref name="list.listTypeAttribute"/>
      <optional>
         <attribute name="item-label"/>
      </optional>
      <zeroOrMore>
         <interleave>
            <choice>
               <ref name="text.verticalContent"/>
               <ref name="text.horizontalContent"/>
               <text/>
            </choice>
         </interleave>
      </zeroOrMore>
   </element>
</define>

List Item Title

define : list.itemTitleElement
element : list:title
refcommon.commonAttributes
zeroOrMore
interleave
choice
reftext.horizontalContent
Any text
<define name="list.itemTitleElement">
   <element name="list:title">
      <ref name="common.commonAttributes"/>
      <zeroOrMore>
         <interleave>
            <choice>
               <ref name="text.horizontalContent"/>
               <text/>
            </choice>
         </interleave>
      </zeroOrMore>
   </element>
</define>