EBNF Grammar for XML 1.1

Document

[1] document ::= prolog 22 element 39 Misc 27 * - Char 2 * RestrictedChar 2a Char 2 *

Character range

[2] Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */

[2a] RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]

Whitespace

[3] S ::= (#x20 | #x9 | #xD | #xA)+

Names and tokens

[4] 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]

[4a] NameChar ::= NameStartChar 4 | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]

[5] Name ::= NameStartChar 4 ( NameChar 4a )*

[6] Names ::= Name 5 (#x20 Name 5 )*

[7] Nmtoken ::= ( NameChar 4a )+

[8] Nmtokens ::= Nmtoken 7 (#x20 Nmtoken 7 )*

Literals

[9] EntityValue ::= '"' ([^%&"] | PEReference 69 | Reference 67 )* '"' | "'" ([^%&'] | PEReference 69 | Reference 67 )* "'"

[10] AttValue ::= '"' ([^<&"] | Reference 67 )* '"' | "'" ([^<&'] | Reference 67 )* "'"

[11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")

[12] PubidLiteral ::= '"' PubidChar 13 * '"' | "'" ( PubidChar 13 - "'")* "'"

[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'( )+,./:=?;!*#@$_%]

Character data

[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)

Comments

[15] Comment ::= '<!--' (( Char 2 - '-') | ('-' ( Char 2 - '-')))* '-->'

Processing ...

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.