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.

common.commonAttributes — Warning! not used within this schema file. (Combine: choice)
define : common.commonAttributes
Schematron
Uniqueness constraint on id
Context : “*/@id
if not condition “count( //@id[ . = current() ] ) = 1
then output: attribute id not unique in !
optional
attribute : id
data : string
optional
attribute : label
data : string
optional
attribute : lang
data : string
optional
attribute : latex
<define name="common.commonAttributes" combine="choice">
   <sch:pattern name="Uniqueness constraint on id">
      <sch:rule context="*/@id">
         <sch:assert test="count( //@id[ . = current() ] ) = 1">
            <sch:name/>
         </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>

Simple Yes or No type

common.yesNoType (Combine: choice)
define : common.yesNoType
choice
value = "yes"
value = "no"
value = "Yes"
value = "No"
value = "YES"
value = "NO"
<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>

Simple True or False type

common.trueFalseType — Warning! not used within this schema file. (Combine: choice)
define : common.trueFalseType
choice
value = "true"
value = "false"
value = "0"
value = "1"
<define name="common.trueFalseType" combine="choice">
   <choice>
      <value>true</value>
      <value>false</value>
      <value>0</value>
      <value>1</value>
   </choice>
</define>

UK Postcode

common.UKPostcodeType — Warning! not used within this schema file. (Combine: choice)
define : common.UKPostcodeType
data : string
param : 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})"
<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>

A lightweight definition of a URI

common.httpURI — Warning! not used within this schema file. (Combine: choice)
define : common.httpURI
data : anyURI
param : pattern "http://.*"
<define name="common.httpURI" combine="choice">
   <data type="anyURI">
      <param name="pattern">http://.*</param>
   </data>
</define>

A simple domain name

This is of the form xxx, xxx.xxx, xxx.xxx.xxx etc.

common.domainName — Warning! not used within this schema file. (Combine: choice)
define : common.domainName
data : string
param : pattern ".+(\..+)*"
<define name="common.domainName" combine="choice">
   <data type="string">
      <param name="pattern">.+(\..+)*</param>
   </data>
</define>

A simple email address

This is of the form yyy@xxx, yyy@xxx.xxx, yyy@xxx.xxx.xxx etc.

common.emailAddr — Warning! not used within this schema file. (Combine: choice)
define : common.emailAddr
data : string
param : pattern ".+@.+(\..+)*"
<define name="common.emailAddr" combine="choice">
   <data type="string">
      <param name="pattern">.+@.+(\..+)*</param>
   </data>
</define>
common.longMonthString — Warning! not used within this schema file. (Combine: choice)
define : common.longMonthString
choice
value = "January"
value = "February"
value = "March"
value = "April"
value = "May"
value = "June"
value = "July"
value = "August"
value = "September"
value = "October"
value = "November"
value = "December"
<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>