# RelaxNG schema for the "language tag" registry specified in RFC 4646
# and available at http://www.iana.org/assignments/language-subtag-registry

# Not standard in any way, just an individual proposal

# Stephane Bortzmeyer <bortzmeyer@nic.fr>

# TODO: add Schematron rules for constraints such as "Records that
# contain a 'Preferred-Value' field MUST also have a 'Deprecated'
# field. " This specific constraint does not really require
# Schematron, but others may.

start = registry

registry = element registry {date & languages & extlangs & scripts & regions & variants & 
   redundants & grandfathereds} # TODO: extensions

date = element date {xsd:date}

languages = language*

language = element language {subtag & common & scope? & suppress-script? & macrolanguage?}

extlangs = extlang*

extlang = element extlang {subtag & common & scope? & macrolanguage?}

scripts = script*

script = element script {subtag & common}

regions = region*

region = element region {subtag & common}

variants = variant*

variant = element variant {subtag & common & prefix*} # "Records of type 'variant' 
                    # MAY have more than one field of type" 'Prefix'. 

grandfathereds = grandfathered*

grandfathered = element grandfathered {tag & common}

redundants = redundant*

redundant = element redundant {tag & common}

common = added & descriptions & deprecated? & preferred-value?

added = element added {xsd:date}

suppress-script = element suppress-script {text}

descriptions = description+ # Each record MUST contain the following fields

description = element description {text}

subtag = element subtag {text}

tag = element tag {text}

prefix = element prefix {text}

macrolanguage = element macrolanguage {text}

deprecated = element deprecated {xsd:date}

preferred-value = element preferred-value {text}

scope = element scope {text}