document ::=  prolog element Misc* ) - ( CharRestrictedChar Char* )
Char ::=  [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */
RestrictedChar ::=  [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]
S ::=  (#x20 | #x9 | #xD | #xA)+
NameStartChar ::=  ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
NameChar ::=  NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
Name ::=  NameStartChar (NameChar)*
Names ::=  Name (#x20 Name)*
Nmtoken ::=  (NameChar)+
Nmtokens ::=  Nmtoken (#x20 Nmtoken)*
EntityValue ::=  '"' ([^%&"] | PEReferenceReference)* '"'
|  "'" ([^%&'] | PEReferenceReference)* "'"
AttValue ::=  '"' ([^<&"] | Reference)* '"'
|  "'" ([^<&'] | Reference)* "'"
SystemLiteral ::=  ('"' [^"]* '"') | ("'" [^']* "'")
PubidLiteral ::=  '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
PubidChar ::=  #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
CharData ::=  [^<&]* - ([^<&]* ']]>' [^<&]*)
Comment ::=  '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
PI ::=  '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
PITarget ::=  Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
CDSect ::=  CDStart CData CDEnd
CDStart ::=  '<![CDATA['
CData ::=  (Char* - (Char* ']]>' Char*))
CDEnd ::=  ']]>'
prolog ::=  XMLDecl Misc* (doctypedecl Misc*)?
XMLDecl ::=  '<?xml' VersionInfo EncodingDeclSDDeclS? '?>'
VersionInfo ::=  S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
Eq ::=  S? '=' S?
VersionNum ::=  '1.1'
Misc ::=  CommentPIS
doctypedecl ::=  '<!DOCTYPE' S Name (S ExternalID)? S? ('[' intSubset ']' S?)? '>' [VC: Root Element Type]
[WFC: External Subset]
DeclSep ::=  PEReferenceS [WFC: PE Between Declarations]
intSubset ::=  (markupdeclDeclSep)*
markupdecl ::=  elementdeclAttlistDeclEntityDeclNotationDeclPIComment [VC: Proper Declaration/PE Nesting]
[WFC: PEs in Internal Subset]
extSubset ::=  TextDeclextSubsetDecl
extSubsetDecl ::=  markupdeclconditionalSectDeclSep)*
SDDecl ::=  S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) [VC: Standalone Document Declaration]
element ::=  EmptyElemTag
STag content ETag [WFC: Element Type Match]
[VC: Element Valid]
STag ::=  '<' Name (S Attribute)* S? '>' [WFC: Unique Att Spec]
Attribute ::=  Name Eq AttValue [VC: Attribute Value Type]
[WFC: No External Entity References]
[WFC: No < in Attribute Values]
ETag ::=  '</' Name S? '>'
content ::=  CharData? ((elementReferenceCDSectPICommentCharData?)*
EmptyElemTag ::=  '<' Name (S Attribute)* S? '/>' [WFC: Unique Att Spec]
elementdecl ::=  '<!ELEMENT' S Name S contentspec S? '>' [VC: Unique Element Type Declaration]
contentspec ::=  'EMPTY' | 'ANY' | Mixedchildren
children ::=  (choiceseq) ('?' | '*' | '+')?
cp ::=  (Namechoiceseq) ('?' | '*' | '+')?
choice ::=  '(' ScpS? '|' Scp )+ S? ')' [VC: Proper Group/PE Nesting]
seq ::=  '(' ScpS? ',' Scp )* S? ')' [VC: Proper Group/PE Nesting]
Mixed ::=  '(' S? '#PCDATA' (S? '|' SName)* S? ')*'
| '(' S? '#PCDATA' S? ')' [VC: Proper Group/PE Nesting]
[VC: No Duplicate Types]
AttlistDecl ::=  '<!ATTLIST' S Name AttDefS? '>'
AttDef ::=  S Name S AttType S DefaultDecl
AttType ::=  StringTypeTokenizedTypeEnumeratedType
StringType ::=  'CDATA'
TokenizedType ::=  'ID' [VC: ID]
[VC: One ID per Element Type]
[VC: ID Attribute Default]
| 'IDREF' [VC: IDREF]
| 'IDREFS' [VC: IDREF]
| 'ENTITY' [VC: Entity Name]
| 'ENTITIES' [VC: Entity Name]
| 'NMTOKEN' [VC: Name Token]
| 'NMTOKENS' [VC: Name Token]
EnumeratedType ::=  NotationTypeEnumeration
NotationType ::=  'NOTATION' S '(' SName (S? '|' SName)* S? ')' [VC: Notation Attributes]
[VC: One Notation Per Element Type]
[VC: No Notation on Empty Element]
[VC: No Duplicate Tokens]
Enumeration ::=  '(' SNmtoken (S? '|' SNmtoken)* S? ')' [VC: Enumeration]
[VC: No Duplicate Tokens]
DefaultDecl ::=  '#REQUIRED' | '#IMPLIED'
| (('#FIXED' S)? AttValue) [VC: Required Attribute]
[VC: Attribute Default Value Syntactically Correct]
[WFC: No < in Attribute Values]
[VC: Fixed Attribute Default]
[WFC: No External Entity References]
conditionalSect ::=  includeSectignoreSect
includeSect ::=  '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>' [VC: Proper Conditional Section/PE Nesting]
ignoreSect ::=  '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>' [VC: Proper Conditional Section/PE Nesting]
ignoreSectContents ::=  Ignore ('<![' ignoreSectContents ']]>' Ignore)*
Ignore ::=  Char* - (Char* ('<![' | ']]>') Char*)
CharRef ::=  '&#' [0-9]+ ';'
| '&#x' [0-9a-fA-F]+ ';' [WFC: Legal Character]
Reference ::=  EntityRefCharRef
EntityRef ::=  '&' Name ';' [WFC: Entity Declared]
[VC: Entity Declared]
[WFC: Parsed Entity]
[WFC: No Recursion]
PEReference ::=  '%' Name ';' [VC: Entity Declared]
[WFC: No Recursion]
[WFC: In DTD]
EntityDecl ::=  GEDeclPEDecl
GEDecl ::=  '<!ENTITY' S Name S EntityDef S? '>'
PEDecl ::=  '<!ENTITY' S '%' S Name S PEDef S? '>'
EntityDef ::=  EntityValue | (ExternalID NDataDecl?)
PEDef ::=  EntityValueExternalID
ExternalID ::=  'SYSTEM' S SystemLiteral
| 'PUBLIC' S PubidLiteral S SystemLiteral
NDataDecl ::=  S 'NDATA' S Name [VC: Notation Declared]
TextDecl ::=  '<?xml' VersionInfoEncodingDecl S? '?>'
extParsedEnt ::=  TextDeclcontent ) - ( CharRestrictedChar Char* )
EncodingDecl ::=  S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )
EncName ::=  [A-Za-z] ([A-Za-z0-9._] | '-')* /* Encoding name contains only Latin characters */
NotationDecl ::=  '<!NOTATION' S Name S (ExternalIDPublicIDS? '>' [VC: Unique Notation Name]
PublicID ::=  'PUBLIC' S PubidLiteral