The following grammar provides the EBNF productions for the XML 1.1 recommendation.
[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]
[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 )*
[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] | [-'( )+,./:=?;!*#@$_%]
[16] PI ::= '<?'
PITarget
17 ( S
3
( Char
2 * - (
Char
2 * '?>' Char
2 *)))?
'?>
'
[17] PITarget ::= Name
5 - (('X' |
'x') ('M' | 'm') ('L' | 'l'))
[18] CDSect ::= CDStart
19 CData
20
CDEnd
21
[19] CDStart ::=
'<![CDATA[
'
[20] CData ::= ( Char
2 * - (
Char
2 * ']]>' Char
2 *))
[21] CDEnd ::=
']]>
'
[22] prolog ::= XMLDecl
23 Misc
27
* ( doctypedecl
28 Misc
27
*)?
[23] XMLDecl ::= '<?xml'
VersionInfo
24 EncodingDecl
80 ?
SDDecl
32 ? S
3
?'?>
'
[24] VersionInfo ::= S
3 'version'
Eq
25 ("'" VersionNum
26 "'" | '"'
VersionNum
26 '"')
[25] Eq ::= S
3 ? '='
S
3 ?
[26] VersionNum ::=
'1.1
'
[27] Misc ::= Comment
15 |
PI
16 | S
3
[28] doctypedecl ::= '<!DOCTYPE'
S
3 Name
5
( S
3 ExternalID)?
S
3 ? ('[' intSubset
28b']'
S
3 ?)? '>
'
[28a] DeclSep ::=
PEReference
69 | S
3
[28b] intSubset ::= (
markupdecl
29 | DeclSep
28a
)*
[29] markupdecl ::=
elementdecl
45 | AttlistDecl
52 |
EntityDecl
70 | NotationDecl
82 |
PI
16 | Comment
15
[30] extSubset ::=
TextDecl
77 ? extSubsetDecl
31
[31] extSubsetDecl ::= (
markupdecl
29 | conditionalSect
61 |
DeclSep
28a )*
[32] SDDecl ::= #x20+ 'standalone'
Eq
25 (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')
'"'))
[40] STag ::= '<' Name
5 (
S
3 Attribute
41
)* S
3 ?
'>
'
[41] Attribute ::= Name Eq
AttValue
[43] content ::= CharData
14 ? ((
element
39 | Reference
67 |
CDSect
18 | PI
16
| Comment
15 )
CharData
14 ?)*
[45] elementdecl ::= '<!ELEMENT'
S
3 Name
5
S
3
contentspec
46 S
3 ?
'>
'
[46] contentspec ::= 'EMPTY' |
'ANY' | Mixed
51 | children
47
[47] children ::= (
choice
49 | seq
50
) ('?' | '*' | '+')?
[48] cp ::= ( Name
5 |
choice
49 | seq
50
) ('?' | '*' | '+')?
[49] choice ::= '(' S
3 ?
cp
48 ( S
3
? '|' S
3 ?
cp
48 )+ S
3
? ')
'
[50] seq ::= '(' S
3 ?
cp
48 ( S
3
? ',' S
3 ?
cp
48 )* S
3
? ')
'
[51] Mixed ::= '(' S
3 ? '#PCDATA'
( S
3 ? '|' S
3
? Name
5 )*
S
3 ? ')*' | '(' S
3 ? '#PCDATA'
S
3 ? ')
'
[52] AttlistDecl ::= '<!ATTLIST'
S
3 Name
5
AttDef
53 *
S
3 ? '>
'
[53] AttDef ::= S
3 Name
3
S
3
AttType
3 S
3 DefaultDecl
3
[54] AttType ::=
StringType
55 | TokenizedType
56 |
EnumeratedType
57
[55] StringType ::=
'CDATA
'
[56] TokenizedType ::=
'ID
'
| 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS'
[57] EnumeratedType ::=
NotationType
58 | Enumeration
59
[58] NotationType ::= 'NOTATION'
S
3'(' S
3
? Name
5 (
S
3 ? '|' S
3
? Name
5 )*
S
3 ? ')
'
[59] Enumeration ::= '('
S
3 ? Nmtoken
7
( S
3 ? '|'
S
3 ? Nmtoken
7
)* S
3 ?
')
'
[61] conditionalSect ::=
includeSect
62 | ignoreSect
63
[62] includeSect ::= '<!['
S
3 ? 'INCLUDE' S
3 ? '['
extSubsetDecl
31']]>
'
[63] ignoreSect ::= '<!['
S
3 ? 'IGNORE' S
3 ? '['
ignoreSectContents
64
* ']]>
'
[64] ignoreSectContents ::=
Ignore
65 ('<![' ignoreSectContents
64']]>'
Ignore
65 )*
[65] Ignore ::= Char
2 * - (
Char
2 * ('<![' | ']]>') Char
2 *)
[67] Reference ::=
EntityRef
68 | CharRef
66
[68] EntityRef ::= '&'
Name
5';
'
[69] PEReference ::= '%'
Name
5';
'
[70] EntityDecl ::=
GEDecl
71 | PEDecl
72
[71] GEDecl ::= '<!ENTITY'
S
3 Name
5
S
3
EntityDef
73 S
3 ?
'>
'
[72] PEDecl ::= '<!ENTITY'
S
3'%' S
3
Name
5 S
3 PEDef
74
S
3
? '>
'
[73] EntityDef ::=
EntityValue
9 | ( ExternalID
75 NDataDecl
76
?)
[74] PEDef ::=
EntityValue
9 | ExternalID
75
[75] ExternalID ::= 'SYSTEM'
S
3 SystemLiteral
11 | 'PUBLIC'
S
3 PubidLiteral
12 S
3 SystemLiteral
11
[76] NDataDecl ::= S
3 'NDATA'
S
3 Name
5
[78] extParsedEnt ::=
TextDecl
77 ? content
43
- Char
2 *
RestrictedChar
2a Char
2
*
[80] EncodingDecl ::= S
3 'encoding'
Eq
25 ('"' EncName
81'"' | "'"
EncName
81"'" )
[81] EncName ::= [A-Za-z]
([A-Za-z0-9._] | '-')* /* Encoding name contains only Latin
characters */