namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
namespace ns1 = "http://www.w3.org/2000/svg"

# xml2rfc Version 3 grammar
rfc =
  element rfc {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute number { text }?,
    [ a:defaultValue = "" ] attribute obsoletes { text }?,
    [ a:defaultValue = "" ] attribute updates { text }?,
    attribute category { text }?,
    attribute mode { text }?,
    [ a:defaultValue = "false" ]
    attribute consensus { "no" | "yes" | "false" | "true" }?,
    attribute seriesNo { text }?,
    attribute ipr {
      "full2026"
      | "noDerivativeWorks2026"
      | "none"
      | "full3667"
      | "noModification3667"
      | "noDerivatives3667"
      | "full3978"
      | "noModification3978"
      | "noDerivatives3978"
      | "trust200811"
      | "noModificationTrust200811"
      | "noDerivativesTrust200811"
      | "trust200902"
      | "noModificationTrust200902"
      | "noDerivativesTrust200902"
      | "pre5378Trust200902"
    }?,
    attribute iprExtract { xsd:IDREF }?,
    [ a:defaultValue = "IETF" ]
    attribute submissionType {
      "IETF" | "IAB" | "IRTF" | "independent"
    }?,
    attribute docName { text }?,
    [ a:defaultValue = "false" ]
    attribute sortRefs { "true" | "false" }?,
    [ a:defaultValue = "true" ]
    attribute symRefs { "true" | "false" }?,
    [ a:defaultValue = "true" ]
    attribute tocInclude { "true" | "false" }?,
    [ a:defaultValue = "3" ] attribute tocDepth { text }?,
    attribute prepTime { text }?,
    [ a:defaultValue = "true" ]
    attribute indexInclude { "true" | "false" }?,
    attribute version { text }?,
    [ a:defaultValue = "Common,Latin" ] attribute scripts { text }?,
    attribute expiresDate { text }?,
    link*,
    front,
    middle,
    back?
  }
link =
  element link {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute href { text },
    attribute rel { text }?
  }
front =
  element front {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    title,
    author+,
    date?,
    area*,
    workgroup*,
    keyword*,
    abstract?,
    seriesInfo*,
    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 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 }?,
    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+)
  }
street =
  element street {
    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
  }
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 { text }?,
    (dl | ol | t | ul)+
  }
note =
  element note {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute title { text }?,
    attribute pn { text }?,
    [ a:defaultValue = "false" ]
    attribute removeInRFC { "true" | "false" }?,
    name?,
    (dl | ol | t | ul)+
  }
boilerplate =
  element boilerplate {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute pn { text }?,
    section+
  }
middle =
  element middle {
    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 { text }?,
    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
     | blockquote
     | dl
     | figure
     | iref
     | ol
     | sourcecode
     | t
     | table
     | texttable
     | ul)*,
    section*
  }
name =
  element name {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute slugifiedName { text }?,
    (text | cref | eref | relref | tt | xref)*
  }
t =
  element t {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    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
     | vspace
     | xref)*
  }
aside =
  element aside {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    (artwork | dl | figure | iref | \list | ol | t | table | ul)*
  }
blockquote =
  element blockquote {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    attribute cite { text }?,
    attribute quotedFrom { text }?,
    ((artwork | dl | figure | ol | sourcecode | t | ul)+
     | (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | strong
        | sub
        | sup
        | tt
        | xref)+)
  }
\list =
  element list {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    [ a:defaultValue = "empty" ] attribute style { text }?,
    attribute hangIndent { text }?,
    attribute counter { text }?,
    t+
  }
ol =
  element ol {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    [ a:defaultValue = "1" ] attribute type { text }?,
    [ a:defaultValue = "1" ] attribute start { text }?,
    attribute group { text }?,
    [ a:defaultValue = "normal" ]
    attribute spacing { "normal" | "compact" }?,
    li+
  }
ul =
  element ul {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    [ a:defaultValue = "normal" ]
    attribute spacing { "normal" | "compact" }?,
    [ a:defaultValue = "false" ]
    attribute empty { "false" | "true" }?,
    li+
  }
li =
  element li {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    ((artwork | dl | figure | ol | sourcecode | t | ul)+
     | (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | strong
        | sub
        | sup
        | tt
        | xref)+)
  }
dl =
  element dl {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    [ a:defaultValue = "normal" ]
    attribute spacing { "normal" | "compact" }?,
    [ a:defaultValue = "true" ]
    attribute hanging { "false" | "true" }?,
    (dt, dd)+
  }
dt =
  element dt {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    (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 { text }?,
    ((artwork | dl | figure | ol | sourcecode | t | ul)+
     | (text
        | bcp14
        | cref
        | em
        | eref
        | iref
        | relref
        | strong
        | sub
        | sup
        | tt
        | 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 }?,
    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 section { text },
     attribute relative { text }?)?,
    attribute derivedRemoteContent { 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" }?,
    [ a:defaultValue = "" ] attribute irefid { text }?,
    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 { text }?,
    [ a:defaultValue = "" ] attribute title { text }?,
    [ a:defaultValue = "false" ]
    attribute suppress-title { "true" | "false" }?,
    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 }?,
    name?,
    iref*,
    preamble?,
    (artwork | sourcecode)+,
    postamble?
  }
table =
  element table {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    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
     | xref)*
  }
artwork =
  element artwork {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    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)
  }
svg =
  element ns1:svg {
    [ a:defaultValue = "can be found in draft-brownlee-svg-rfc" ]
    attribute TheRealDefinition { text }*,
    # temporary added to make my validation work.
    attribute xml:base { text }?,
    attribute xml:lang { text }?
  }
sourcecode =
  element sourcecode {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    [ a:defaultValue = "" ] attribute name { text }?,
    [ a:defaultValue = "" ] attribute type { text }?,
    attribute src { text }?,
    attribute originalSrc { text }?,
    text
  }
thead =
  element thead {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    tr+
  }
tbody =
  element tbody {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    tr+
  }
tfoot =
  element tfoot {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    tr+
  }
tr =
  element tr {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    [ a:defaultValue = "0" ] attribute border { text }?,
    (td | th)+
  }
td =
  element td {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    [ a:defaultValue = "0" ] attribute border { text }?,
    [ a:defaultValue = "0" ] attribute colspan { text }?,
    [ a:defaultValue = "0" ] attribute rowspan { text }?,
    [ a:defaultValue = "left" ]
    attribute align { "left" | "center" | "right" }?,
    (t+
     | (text
        | artwork
        | bcp14
        | br
        | cref
        | dl
        | em
        | eref
        | figure
        | iref
        | ol
        | relref
        | sourcecode
        | strong
        | sub
        | sup
        | tt
        | ul
        | xref)+)
  }
th =
  element th {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute pn { text }?,
    [ a:defaultValue = "0" ] attribute border { text }?,
    [ a:defaultValue = "0" ] attribute colspan { text }?,
    [ a:defaultValue = "0" ] attribute rowspan { text }?,
    [ a:defaultValue = "left" ]
    attribute align { "left" | "center" | "right" }?,
    (t+
     | (text
        | artwork
        | bcp14
        | br
        | cref
        | dl
        | em
        | eref
        | figure
        | iref
        | ol
        | relref
        | sourcecode
        | strong
        | sub
        | sup
        | tt
        | ul
        | 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
  }
br =
  element br {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    empty
  }
back =
  element back {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    displayreference*,
    references*,
    section*
  }
displayreference =
  element displayreference {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute target { xsd:IDREF },
    attribute to { text }
  }
references =
  element references {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID }?,
    attribute title { text }?,
    name?,
    (reference | referencegroup)*
  }
reference =
  element reference {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID },
    attribute target { text }?,
    [ a:defaultValue = "true" ]
    attribute quoteTitle { "true" | "false" }?,
    front,
    (annotation | format | refcontent | seriesInfo)*
  }
referencegroup =
  element referencegroup {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute anchor { xsd:ID },
    reference+
  }
seriesInfo =
  element seriesInfo {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    attribute name { text },
    attribute value { text },
    attribute asciiName { text }?,
    attribute asciiValue { text }?,
    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
     | xref)*
  }
refcontent =
  element refcontent {
    attribute xml:base { text }?,
    attribute xml:lang { text }?,
    (text | bcp14 | em | strong | sub | sup | tt)*
  }
start = rfc
