   namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"

   # xml2rfc <reference> grammar

   reference =
     element reference {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID },
       attribute derivedAnchor { text }?,
       attribute target { text }?,
       [ a:defaultValue = "true" ]
       attribute quoteTitle { "true" | "false" }?,
       attribute quote-title { "true" | "false" }?,
       stream?,
       front,
       (annotation | format | refcontent | seriesInfo)*
     }

   front =
     element front {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       title,
       seriesInfo*,
       author+,
       date?,
       area*,
       workgroup*,
       keyword*,
       abstract?,
       note*,
       boilerplate?
     }

   title =
     element title {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute abbrev { text }?,
       attribute ascii { text }?,
       text
     }

   author =
     element author {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute initials { text }?,
       attribute asciiInitials { text }?,
       attribute surname { text }?,
       attribute asciiSurname { text }?,
       attribute fullname { text }?,
       attribute role { "editor" }?,
       attribute asciiFullname { text }?,
       organization?,
       address?
     }

   organization =
     element organization {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute abbrev { text }?,
       attribute ascii { text }?,
       attribute asciiAbbrev { text }?,
       text
     }

   address =
     element address {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       postal?,
       phone?,
       facsimile?,
       email?,
       uri?
     }

   postal =
     element postal {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       ((city | code | country | region | street)* 
        | postalLine+
        | (city? 
           & cityarea? 
           & code? 
           & country 
           & extaddr*
           & pobox?
           & region?
           & sortingcode? 
           & street*))
     }

   extaddr =
     element extaddr {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   pobox =
     element pobox {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   street =
     element street {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   cityarea =
     element cityarea {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   city =
     element city {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   region =
     element region {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   code =
     element code {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   sortingcode =
     element sortingcode {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   country =
     element country {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   postalLine =
     element postalLine {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   phone =
     element phone {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       text
     }

   facsimile =
     element facsimile {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       text
     }

   email =
     element email {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute ascii { text }?,
       text
     }

   uri =
     element uri {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       text
     }

   date =
     element date {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute day { text }?,
       attribute month { text }?,
       attribute year { text }?,
       empty
     }

   area =
     element area {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       text
     }

   workgroup =
     element workgroup {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       text
     }

   keyword =
     element keyword {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       text
     }

   abstract =
     element abstract {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       (dl | ol | t | ul)+
     }

   note =
     element note {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute title { text }?,
       attribute pn { xsd:ID }?,
       [ a:defaultValue = "false" ]
       attribute removeInRFC { "true" | "false" }?,
       name?,
       (dl | ol | t | ul)+
     }

   boilerplate =
     element boilerplate {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       section+
     }

   section =
     element section {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       attribute title { text }?,
       [ a:defaultValue = "true" ]
       attribute numbered { "true" | "false" }?,
       [ a:defaultValue = "default" ]
       attribute toc { "include" | "exclude" | "default" }?,
       [ a:defaultValue = "false" ]
       attribute removeInRFC { "true" | "false" }?,
       name?,
       (artwork
        | aside
	| author
        | blockquote
        | dl
        | figure
        | iref
        | ol
        | sourcecode
        | t
        | table
        | texttable
        | ul)*,
       section*
     }

   name =
     element name {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute slugifiedName { xsd:ID }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | strong
        | sub
        | sup
        | tt
        | xref)*
     }

   t =
     element t {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       attribute hangText { text }?,
       [ a:defaultValue = "false" ]
       attribute keepWithNext { "false" | "true" }?,
       [ a:defaultValue = "false" ]
       attribute keepWithPrevious { "false" | "true" }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | \list
        | relref
        | spanx
        | strong
        | sub
        | sup
        | tt
        | u
        | vspace
        | xref)*
     }

   aside =
     element aside {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       (artwork | dl | figure | iref | ol | t | table | ul)*
     }

   blockquote =
     element blockquote {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       attribute cite { text }?,
       attribute quotedFrom { text }?,
       ((artwork | dl | figure | ol | sourcecode | t | ul)+
        | (text
           | bcp14
           | cref
           | em
           | eref
           | iref
           | relref
           | strong
           | sub
           | sup
           | tt
           | u
           | xref)+)
     }

   \list =
     element list {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       [ a:defaultValue = "empty" ] attribute style { text }?,
       attribute hangIndent { text }?,
       attribute counter { text }?,
       attribute pn { xsd:ID }?,
       t+
     }

   ol =
     element ol {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       [ a:defaultValue = "1" ] attribute type { text }?,
       [ a:defaultValue = "1" ] attribute start { text }?,
       attribute group { text }?,
       [ a:defaultValue = "normal" ]
       attribute spacing { "normal" | "compact" }?,
       attribute pn { xsd:ID }?,
       li+
     }

   ul =
     element ul {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       [ a:defaultValue = "normal" ]
       attribute spacing { "normal" | "compact" }?,
       ([ a:defaultValue = "false" ]
        attribute empty { "false" | "true"},
	[ a:defaultValue = "false" ]
        attribute bare { "false" | "true"}?,
        attribute pn { xsd:ID }?)?,
       li+
     }

   li =
     element li {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute derivedCounter { text }?,
       attribute pn { xsd:ID }?,
       ((artwork | blockquote | dl | figure | ol | sourcecode | t | ul)+
        | (text
           | bcp14
           | cref
           | em
           | eref
           | iref
           | relref
           | strong
           | sub
           | sup
           | tt
           | u
           | xref)+)
     }

   dl =
     element dl {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       [ a:defaultValue = "normal" ]
       attribute spacing { "normal" | "compact" }?,
       [ a:defaultValue = "false" ]
       attribute newline { "false" | "true" }?,
       attribute indent { text }?,
       attribute pn { xsd:ID }?,
       (dt, dd)+
     }

   dt =
     element dt {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | strong
        | sub
        | sup
        | tt
        | xref)*
     }

   dd =
     element dd {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       ((artwork | dl | figure | ol | sourcecode | t | ul)+
        | (text
           | bcp14
           | cref
           | em
           | eref
           | iref
           | relref
           | strong
           | sub
           | sup
           | tt
           | u
           | xref)+)
     }

   xref =
     element xref {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute target { xsd:IDREF },
       [ a:defaultValue = "false" ]
       attribute pageno { "true" | "false" }?,
       [ a:defaultValue = "default" ]
       attribute format { "default" | "title" | "counter" | "none" }?,
       attribute derivedContent { text }?,
       [ a:defaultValue = "of" ]
       attribute sectionFormat { "of" | "comma" | "parens" | "bare" }?,
       attribute section { text }?,
       attribute relative { text }?,
       attribute derivedLink { text }?,
       text
     }

   relref =
     element relref {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute target { xsd:IDREF },
       [ a:defaultValue = "of" ]
       attribute displayFormat { "of" | "comma" | "parens" | "bare" }?,
       attribute derivedContent { text }?,
       attribute section { text },
       attribute relative { text }?,
       attribute derivedLink { text }?,
       text
     }

   eref =
     element eref {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute target { text },
       text
     }

   iref =
     element iref {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute item { text },
       [ a:defaultValue = "" ] attribute subitem { text }?,
       [ a:defaultValue = "false" ]
       attribute primary { "true" | "false" }?,
       attribute pn { xsd:ID }?,
       empty
     }

   cref =
     element cref {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute source { text }?,
       [ a:defaultValue = "true" ]
       attribute display { "true" | "false" }?,
       (text | em | eref | relref | strong | sub | sup | tt | xref)*
     }

   tt =
     element tt {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | strong
        | sub
        | sup
        | xref)*
     }

   strong =
     element strong {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | sub
        | sup
        | tt
        | xref)*
     }

   em =
     element em {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text
        | bcp14
        | cref
        | eref
        | iref
        | relref
        | strong
        | sub
        | sup
        | tt
        | xref)*
     }

   sub =
     element sub {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | strong
        | tt
        | xref)*
     }

   sup =
     element sup {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | strong
        | tt
        | xref)*
     }

   spanx =
     element spanx {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       [ a:defaultValue = "preserve" ]
       attribute xml:space { "default" | "preserve" }?,
       [ a:defaultValue = "emph" ] attribute style { text }?,
       text
     }

   vspace =
     element vspace {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       [ a:defaultValue = "0" ] attribute blankLines { text }?,
       empty
     }

   figure =
     element figure {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       [ a:defaultValue = "" ] attribute title { text }?,
       [ a:defaultValue = "false" ]
       attribute suppress-title { "true" | "false" }?,
       attribute src { text }?,
       attribute originalSrc { text }?,
       [ a:defaultValue = "left" ]
       attribute align { "left" | "center" | "right" }?,
       [ a:defaultValue = "" ] attribute alt { text }?,
       [ a:defaultValue = "" ] attribute width { text }?,
       [ a:defaultValue = "" ] attribute height { text }?,
       name?,
       iref*,
       preamble?,
       (artwork | sourcecode)+,
       postamble?
     }

   table =
     element table {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       [ a:defaultValue = "center" ]
       attribute align { "left" | "center" | "right" }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       name?,
       iref*,
       thead?,
       tbody+,
       tfoot?
     }

   preamble =
     element preamble {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | spanx
        | strong
        | sub
        | sup
        | tt
        | u
        | xref)*
     }

   artwork =
     element artwork {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       attribute xml:space { text }?,
       [ a:defaultValue = "" ] attribute name { text }?,
       [ a:defaultValue = "" ] attribute type { text }?,
       attribute src { text }?,
       [ a:defaultValue = "left" ]
       attribute align { "left" | "center" | "right" }?,
       [ a:defaultValue = "" ] attribute alt { text }?,
       [ a:defaultValue = "" ] attribute width { text }?,
       [ a:defaultValue = "" ] attribute height { text }?,
       attribute originalSrc { text }?,
       (text* | svg)
     }
   include "SVG-1.2-RFC.rnc"

   sourcecode =
     element sourcecode {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       attribute pn { xsd:ID }?,
       [ a:defaultValue = "" ] attribute name { text }?,
       [ a:defaultValue = "" ] attribute type { text }?,
       [ a:defaultValue = "false" ] 
       attribute markers { "true" | "false" }?,
       attribute src { text }?,
       attribute originalSrc { text }?,
       text
     }

   thead =
     element thead {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       tr+
     }

   tbody =
     element tbody {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       tr+
     }

   tfoot =
     element tfoot {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       tr+
     }

   tr =
     element tr {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       (td | th)+
     }

   td =
     element td {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       [ a:defaultValue = "1" ] attribute colspan { text }?,
       [ a:defaultValue = "1" ] attribute rowspan { text }?,
       [ a:defaultValue = "left" ]
       attribute align { "left" | "center" | "right" }?,
       ((artwork | dl | figure | ol | sourcecode | t | ul)+
        | (text
           | bcp14
           | cref
           | em
           | eref
           | iref
           | relref
           | strong
           | sub
           | sup
           | tt
           | u
           | xref)*)
     }

   th =
     element th {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       [ a:defaultValue = "1" ] attribute colspan { text }?,
       [ a:defaultValue = "1" ] attribute rowspan { text }?,
       [ a:defaultValue = "left" ]
       attribute align { "left" | "center" | "right" }?,
       ((artwork | dl | figure | ol | sourcecode | t | ul)+
        | (text
           | bcp14
           | cref
           | em
           | eref
           | iref
           | relref
           | strong
           | sub
           | sup
           | tt
           | u
           | xref)*)
     }

   postamble =
     element postamble {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text | cref | eref | iref | spanx | xref)*
     }

   texttable =
     element texttable {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute anchor { xsd:ID }?,
       [ a:defaultValue = "" ] attribute title { text }?,
       [ a:defaultValue = "false" ]
       attribute suppress-title { "true" | "false" }?,
       [ a:defaultValue = "center" ]
       attribute align { "left" | "center" | "right" }?,
       [ a:defaultValue = "full" ]
       attribute style { "all" | "none" | "headers" | "full" }?,
       name?,
       preamble?,
       ttcol+,
       c*,
       postamble?
     }

   ttcol =
     element ttcol {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute width { text }?,
       [ a:defaultValue = "left" ]
       attribute align { "left" | "center" | "right" }?,
       (cref | eref | iref | xref | text)*
     }

   c =
     element c {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text | cref | eref | iref | spanx | xref)*
     }

   bcp14 =
     element bcp14 {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       text
     }

   stream = 
     element stream {
       ( "IETF" | "IAB" | "IRTF" | "independent" )?       
   }


   seriesInfo =
     element seriesInfo {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute name { text },
       attribute value { text },
       attribute asciiName { text }?,
       attribute asciiValue { text }?,
       attribute status { text }?,
       attribute stream { "IETF" | "IAB" | "IRTF" | "independent" }?,
       empty
     }

   format =
     element format {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       attribute target { text }?,
       attribute type { text },
       attribute octets { text }?,
       empty
     }

   annotation =
     element annotation {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | spanx
        | strong
        | sub
        | sup
        | tt
        | u
        | xref)*
     }

   refcontent =
     element refcontent {
       attribute xml:base { text }?,
       attribute xml:lang { text }?,
       (text | bcp14 | em | strong | sub | sup | tt)*
     }

   u = 
     element u {
       attribute anchor { xsd:ID }?,
       attribute ascii { text }?,
       [ a:defaultValue = "lit-name-num" ]
       attribute format { text }?,
       attribute pn { xsd:ID }?,
       text
     }

   start |= reference

