foo = xsd:token foo = xsd:token { minLength = "2" maxLength = "17" } foo = "stuff" foo = xsd:integer "1" | xsd:integer "2" foo = xsd:integer "1" | xsd:double "1.0" foo = list { xsd:int* } foo = list { xsd:int+ } foo = list { xsd:int, xsd:int+ } foo = list { empty } foo = list { notAllowed } | xsd:int foo = empty, xsd:int foo = xsd:int* foo = element foo { empty } foo = element foo { attribute bar { xsd:double }, (xsd:int | xsd:boolean) } foo = element foo { bar } bar = xsd:int | xsd:boolean bar = element bar { foo } foo = attribute foo { xsd:double } | element foo { xsd:double } start = foo foo = element foo { empty } start = root root = foo|bar foo = element foo { empty } bar = element bar { empty } element foo { empty } | element bar { empty } bar = element bar { empty } baz = element baz { empty } foo = element foo { bar | baz } include "bar.rnc" namespace eg = "http://www.example.com" element eg:foo { empty } default namespace = "http://www.example.com" element foo { empty } start = element foo { empty } default namespace = "http://www.example.com" include "foo.rnc" namespace e1 = "http://www.example.com/1" namespace e2 = "http://www.example.com/2" element e1:x { element e2:y { empty } } namespace e1 = "http://www.example.com/1" element e1:x { element y { empty } } namespace e1 = "http://www.example.com/1" element e1:x { element y { element e1:z { empty } } } namespace e1 = "http://www.example.com/1" namespace e2 = "http://www.example.com/2" element e1:x { element e2:y { element e1:z { empty } } } namespace e1 = "http://www.example.com/1" namespace e2 = "http://www.example.com/2" element e1:x { empty } | element e2:y { empty } namespace e1 = "http://www.example.com/1" namespace e2 = "http://www.example.com/2" start = x | y x = element e1:x { y? } y = element e2:y { x? } namespace e1 = "http://www.example.com/1" element e1:x { attribute e1:a { text } } namespace e1 = "http://www.example.com/1" element x { empty } | element e1:y { empty } namespace eg = "http://www.example.com" start = element eg:y { x } x = element x { empty } include "example.rnc" namespace eg = "http://www.example.com" element x { attribute eg:y { text } } element foo|bar|baz { empty } start = root root = element foo|bar|baz { empty } element foo { attribute bar|baz { text } } namespace e1 = "http://www.example.com/1" namespace e2 = "http://www.example.com/2" element e1:x { element e2:y|e2:z { element e2:y { empty } } } namespace e1 = "http://www.example.com/1" namespace e2 = "http://www.example.com/2" namespace e3 = "http://www.example.com/3" element e1:x { element e2:y|e3:z { element e1:x|e1:v { empty } } } | element e1:w { element e2:y { text } } namespace e1 = "http://www.example.com/1" namespace e2 = "http://www.example.com/2" element e1:x { element e1:x|e2:y { element e1:x|e2:y { empty } } } start = element foo { bar } bar = element bar { bar* } element foo { attribute xml:lang { xsd:language } } | element bar { attribute xml:lang { xsd:language } } element foo { attribute bar { text }, xsd:float } start = element foo { int|double|float } int = attribute type { "int" }, xsd:int double = attribute type { "double" }, xsd:double float = attribute type { "float" }, xsd:float start = element foo { atts } | element bar { atts? } atts = attribute a1 { text }, more-atts more-atts = attribute a2 { text }? element foo { attribute bar { text } | attribute bar { xsd:float } } start = element foo { bar1 | bar2 } bar1 = attribute bar { text }, attribute baz1 { text }? bar2 = attribute bar { xsd:float }, attribute baz2 { text }? namespace eg = "http://www.example.com" namespace local = "" element eg:foo { attribute * - (eg:*|local:*) { text }* } namespace eg1 = "http://www.example.com/1" namespace eg2 = "http://www.example.com/2" start = element foo { eg1, eg2 } eg1 = attribute eg1:* { text } * eg2 = attribute eg2:* { text } * namespace eg1 = "http://www.example.com/1" namespace eg2 = "http://www.example.com/2" start = element foo { eg1, eg2 } eg1 = attribute eg1:*|eg2:* { text } * eg2 = attribute eg2:* { text } * namespace eg1 = "http://www.example.com/1" namespace eg2 = "http://www.example.com/2" start = element foo { eg1, eg2 } eg1 = attribute eg1:* { text } * eg2 = attribute eg1:*|eg2:* { text } * element foo { attribute * - bar { text }+, attribute bar { xsd:float } } namespace eg = "http://www.example.com" namespace local = "" element eg:foo { attribute * - (local:*|(eg:* - eg:bar)) { xsd:float }* } element foo { attribute * { text }* | attribute bar { xsd:string } } element foo { attribute * - bar { text }* | attribute bar { xsd:float } } namespace eg = "http://www.example.com" element foo { attribute eg:* { text }* | attribute bar { xsd:float } | attribute eg:bar { xsd:float } } element foo { element * { text } } foo2 = element foo2 { bar } namespace e2 = "http://www.example.com/2" bar = element e2:bar1 { element baz { empty } } | element e2:bar2 { element baz { text } } default namespace = "http://www.example.com/1" include "eg1.rnc" include "eg2.rnc" start = element foo1 { bar } | foo2 namespace eg1 = "http://www.example.com/1" namespace eg2 = "http://www.example.com/2" namespace eg3 = "http://www.example.com/3" element eg2:foo { element * - eg1:* { text }, element * - eg2:* { text }, element * - eg3:* { text } } datatypes x = "http://x.org" element foo { x:bar { pattern = "[a-zA-Z]*" } } element foo { attribute bar { xsd:integer? } } element foo { attribute bar { empty } } element foo { xsd:float? } element foo { attribute bar { text }, xsd:float? } element foo { notAllowed } namespace eg = "http://www.example.com" element eg:foo { element bar { notAllowed } | element baz { text } } element foo { attribute format { xsd:NOTATION "bar" }, text } element foo { attribute format { xsd:NOTATION }, text } element foo { xsd:QName "xyzzy" } default namespace = "http://www.example.com" element foo { xsd:QName "xyzzy" } namespace eg = "http://www.example.com" element foo { xsd:QName "eg:xyzzy" } namespace xs = "http://www.example.com" element foo { xsd:QName "xs:xyzzy" } element foo { xsd:QName "xyzzy" } start = element foo { x } x = element bar { empty }, x? start = element foo { empty } x = element bar { empty }, x? start = element foo { x } y = element bar { z } element foo { empty } externalRef "x.rnc" start = grammar { start = element foo { empty } } start = element foo { parent x } x = empty start = element foo { empty } include "foo.rnc" { start = element foo { text } } element foo { xsd:no-such-datatype } | element bar { xsd:string { pattrn = "[a-zA-Z]+" } } | element baz { xsd:string { maxLength = "2in" } } start = element foo { xsd:gdday-bruce } include "bad.rnc" element foo { empty } include "bad.rnc" start = element foo { xsd:gdday-bruce } include "bad.rnc" inline = element em { text } inline |= element code { text } inline = element b { text } inline = element em { text } inline |= element code { text } inline |= element code { text } inline = element em { text } inline |= element code { text } inline = element em { text } inline |= element b { text } include "foo.rnc" include "foo.rnc" foo |= element foo { empty } include "foo.rnc" include "foo.rnc" , except that # John Cowan retains the moral right to be known as the author. # This is draft 6.2 # Diff from 6.1: rel|rel now rel|rev, th|td@headers now IDREFS, # table width no longer an integer, non-basic table attrs gone, # rowspan and colspan must be non-negative # Diff from 6.0: added attributes to ul, comment about img, new meta # This is a RELAX NG schema which describes a subset of XHTML Basic for # use within other schemas. It is by intention equivalent # (within its scope) to -//W3C//DTD XHTML 1.1//EN, but is # not a derived work in the copyright sense. # It is often convenient for XML documents to have a bit of # documentation somewhere in them. In the absence of a schema like # this one, that documentation winds up being only, which is # a pity, because rich text adds measurably to the readability of # documents. By incorporating this schema by reference (as an # external parameter entity) into another schema, that schema inherits # the capabilities of this one. Using HTML-compatible elements # and attributes allows the documentation to be passed straight # through to HTML renderers. # Current HTML renderers can cope with most XML tags, but empty # tags require special treatment. Inserting a space before the # terminating "/>" usually makes the "/" (which is not HTML) # invisible. Using "" is not as effective, as the # latter is often misinterpreted as a second "". # Note that since the elements of this schema are intended to be # used within domain-specific elements of the surrounding DTD, # it is not necessary that every fragment begin with an "html" # element, as in HTML. Recommended s for elements # containing documentation are "horiz.model" for simple # text fragments and "struct.model" for documents in extenso. # Declarations datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes" # Common attributes # All elements (except full-document elements) can have these attributes all = attribute id {xsd:ID}?, attribute class {token}?, attribute title {text}? # All non-empty elements can have these attributes i18n = attribute xml:lang {text}?, attribute dir {"ltr" | "rtl"}? basic = all, i18n # Models t = text horiz.model = basic & t & horiz* vert.model = basic & t & (horiz|vert)* struct.model = basic & vert* # Horizontal formatting elements horiz = a | br | horiz.other a = element a { attribute href {xsd:anyURI}?, attribute name {text}?, attribute rel | rev {xsd:anyURI}?, horiz.model } br = element br {all, empty} horiz.other = element abbr | acronym | cite | code | dfn | em | img | kbd | q | samp | span | strong | var {horiz.model} # Vertical formatting elements vert = header | List | table | vert.other header = element h1 | h2 | h3 {horiz.model} List = element dl {basic, element dt | dd {horiz.model}+ } | element ol|ul {basic, element li {horiz.model}+ } aligns = attribute align {"left" | "center" | "right" | "justified"}?, attribute valign {"top" | "middle" | "bottom" | "baseline"}? table = element table { basic, attribute summary {text}?, element caption {horiz.model}?, element tr { basic, aligns, tabledata+}+ } tabledata = element th | td { aligns, attribute abbr {text}?, attribute axis {text}?, attribute colspan {xsd:nonNegativeInteger}?, attribute headers {xsd:IDREFS}?, attribute rowspan {xsd:nonNegativeInteger}?, attribute scope {"row" | "col" | "rowgroup" | "colgroup"}?, vert.model } vert.other = element address {horiz.model} | element blockquote {attribute cite {xsd:anyURI}?, struct.model} | element div {struct.model} | element p {horiz.model} | element pre {horiz.model} # Support for complete HTML documents start = element html { i18n, attribute xml:base {xsd:anyURI}?, attribute xml:space {"preserve" | "default"}?, head, element body {basic, vert*} } head = element head { i18n, element title {i18n, text}, element meta { attribute name|http-equiv {token}?, attribute content {text}, empty }* } # END OF ibtwsh.rnc ]]> start = element foo { t } | element bar { t, attribute baz { text }? } t = attribute x { text }, xsd:float foo = element foo { bar } bar = element bar { text }* baz = element baz { bar, element xyzzy { text }* } foo = attribute foo { attribute bar { text } } foo = element foo { empty }, xsd:float start = attribute foo { text } start = element foo { text }? element foo { xsd:float, xsd:float } element foo { xsd:float* } foo = xsd:float* element foo { attribute bar { text } | element bar { text } } element foo { attribute bar { text } | text } element foo { attribute bar { text } | xsd:float } element foo { (attribute bar { text }, element bar { empty }) | attribute baz { text } } element foo { attribute * { xsd:float }* } start = element foo { attribute * { x }* } x = xsd:normalizedString element foo { attribute * { text } } element foo { attribute * { text }+ } element foo { (attribute bar { text }, attribute baz { text })? } ## This is a foo. element foo { empty } This is a foo. element foo { ## This is a bar. attribute bar { text } } This is a bar. element foo { ## The third random name. "baz" } The third random name. ## An x. x = element foo|bar { empty } An x. #0 grammar { #1 foo [] #2 div { #3 foo [] #4 foo = element foo { empty } } #5 foo[] #6 } #7 namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" element foo { [ a:defaultValue="xyzzy" ] attribute bar { text }? } namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" element foo { [ a:defaultValue="en" ] attribute xml:lang { xsd:language }? } value = element large { xsd:long } | element medium { xsd:int } | element small { xsd:short } value = element large { xsd:double } | element medium { xsd:int } | element small { xsd:short } c = element x { t, attribute att { text } } | element y { t } t = xsd:int c = element x { xsd:int, attribute att { text } } | element y { xsd:int } c = element x { t, attribute att { text } } | element y { t } t = element z { empty }* a = element z { empty }* b = a, attribute att { text } c = element x { a } | element y { b } a = element z { empty }* b = attribute att { text } c = element x { a } | element y { b } start = element e { a* } | element f { b* } a = element x | y | z { element v { empty }* } b = element x | y | z { element w { empty }* } element foo { list { xsd:int* } } c = element x { xsd:int { maxInclusive = "72" } } | element y { xsd:int } x = xsd:int y = x z = y c = element a { x } | element b { z } x = xsd:int y = x, attribute att { text } z = y c = element a { x } | element b { z } x = xsd:int, attribute att1 { text } y = xsd:int, attribute att2 { text } c = element a { x } | element b { y } element foo { attribute att { text } | attribute att { text }? } element foo { attribute att1 { text } | attribute att1 { string } | attribute att2 { text }? }