RELAX NG Schema for Common Attributes and Strings
Author: Hugh Field-Richards
Date: 2009-05-27T19:00
The following optional attributes can be used anywhere to provide extra information about the content.
I am not sure about the uniqueness check in the following Schematron rule, treat with caution.
<define name="common.commonAttributes" combine="choice"> <sch:pattern name="Uniqueness constraint on id"> <sch:rule context="*/@id"> <sch:assert test="count( //@id[ . = current() ] ) = 1"> attribute id not unique in </sch:assert> </sch:rule> </sch:pattern> <optional> <attribute name="id"> <data type="string"/> </attribute> </optional> <optional> <attribute name="label"> <data type="string"/> </attribute> </optional> <optional> <attribute name="lang"> <data type="string"/> </attribute> </optional> <optional> <attribute name="latex"> <ref name="common.yesNoType"/> </attribute> </optional> </define>
<define name="common.yesNoType" combine="choice"> <choice> <value> yes </value> <value> no </value> <value> Yes </value> <value> No </value> <value> YES </value> <value> NO </value> </choice> </define>
<define name="common.trueFalseType" combine="choice"> <choice> <value> true </value> <value> false </value> <value> 0 </value> <value> 1 </value> </choice> </define>
<define name="common.UKPostcodeType" combine="choice"> <data type="string"> <param name="pattern"> (GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2}) </param> </data> </define>
<define name="common.httpURI" combine="choice"> <data type="anyURI"> <param name="pattern"> http://.* </param> </data> </define>
This is of the form xxx, xxx.xxx, xxx.xxx.xxx etc.
<define name="common.domainName" combine="choice"> <data type="string"> <param name="pattern"> .+(\..+)* </param> </data> </define>
This is of the form yyy@xxx, yyy@xxx.xxx, yyy@xxx.xxx.xxx etc.
<define name="common.emailAddr" combine="choice"> <data type="string"> <param name="pattern"> .+@.+(\..+)* </param> </data> </define>
<define name="common.longMonthString" combine="choice"> <choice> <value> January </value> <value> February </value> <value> March </value> <value> April </value> <value> May </value> <value> June </value> <value> July </value> <value> August </value> <value> September </value> <value> October </value> <value> November </value> <value> December </value> </choice> </define>