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
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 ;-)
<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.
<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>
We may be able to restrict what goes in list items by invoking the Schematron. This will need investigating.
<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>
<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>