21.6 XML 1.1 Document Grammar

     

The following grammar provides the EBNF productions for the XML 1.1 recommendation.

21.6.1 EBNF Grammar for XML 1.1

21.6.1.1 Document

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

21.6.1.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]

21.6.1.3 Whitespace

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

21.6.1.4 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 )*

21.6.1.5 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] [-'( )+,./:=?;!*#@$_%]

21.6.1.6 Character data

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

21.6.1.7 Comments

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

21.6.1.8 Processing instructions

[16] PI ::= '<?' PITarget 17 ( S 3 ( Char 2 * - ( Char 2 * '?>' Char 2 *)))? '?> '

[17] PITarget ::= Name 5 - (('X' 'x') ('M' 'm') ('L' 'l'))

21.6.1.9 CDATA sections

[18] CDSect ::= CDStart 19 CData 20 CDEnd 21

[19] CDStart ::= '<![CDATA[ '

[20] CData ::= ( Char 2 * - ( Char 2 * ']]>' Char 2 *))

[21] CDEnd ::= ']]> '

21.6.1.10 Prolog

[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

21.6.1.11 Document type definition

[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

21.6.1.12 External subset

[30] extSubset ::= TextDecl 77 ? extSubsetDecl 31

[31] extSubsetDecl ::= ( markupdecl 29 conditionalSect 61 DeclSep 28a )*

21.6.1.13 Standalone document declaration

[32] SDDecl ::= #x20+ 'standalone' Eq 25 (("'" ('yes' 'no') "'") ('"' ('yes' 'no') '"'))

21.6.1.14 Element

[39] element ::= EmptyElemTag 44 STag 40 content 43 ETag 42

21.6.1.15 Start-tag

[40] STag ::= '<' Name 5 ( S 3 Attribute 41 )* S 3 ? '> '

[41] Attribute ::= Name Eq AttValue

21.6.1.16 End-tag

[42] ETag ::= '</' Name 5 S 3 ? '> '

21.6.1.17 Content of elements

[43] content ::= CharData 14 ? (( element 39 Reference 67 CDSect 18 PI 16 Comment 15 ) CharData 14 ?)*

21.6.1.18 Tags for empty elements

[44] EmptyElemTag ::= '<' Name 5 ( S 3 Attribute 41 )* S 3 ? '/> '

21.6.1.19 Element type declaration

[45] elementdecl ::= '<!ELEMENT' S 3 Name 5 S 3 contentspec 46 S 3 ? '> '

[46] contentspec ::= 'EMPTY' 'ANY' Mixed 51 children 47

21.6.1.20 Element-content models

[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 ? ') '

21.6.1.21 Mixed-content declaration

[51] Mixed ::= '(' S 3 ? '#PCDATA' ( S 3 ? '' S 3 ? Name 5 )* S 3 ? ')*' '(' S 3 ? '#PCDATA' S 3 ? ') '

21.6.1.22 Attribute-list declaration

[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

21.6.1.23 Attribute types

[54] AttType ::= StringType 55 TokenizedType 56 EnumeratedType 57

[55] StringType ::= 'CDATA '

[56] TokenizedType ::= 'ID '

 'IDREF'    'IDREFS'    'ENTITY'   'ENTITIES'   'NMTOKEN'    'NMTOKENS' 

21.6.1.24 Enumerated attribute types

[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 ? ') '

21.6.1.25 Attribute defaults

[60] DefaultDecl ::= '#REQUIRED' '#IMPLIED' (('#FIXED' S 3 )? AttValue 10 )

21.6.1.26 Conditional section

[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 *)

21.6.1.27 Character reference

[66] CharRef ::= '&#' [0-9]+ ';' '&#x' [0-9a-fA-F]+ '; '

21.6.1.28 Entity reference

[67] Reference ::= EntityRef 68 CharRef 66

[68] EntityRef ::= '&' Name 5 ' ; '

[69] PEReference ::= '%' Name 5 ' ; '

21.6.1.29 Entity declaration

[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

21.6.1.30 External entity declaration

[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

21.6.1.31 Text declaration

[77] TextDecl ::= '<?xml' VersionInfo 24 ? EncodingDecl 80 S 3 ? '?> '

21.6.1.32 Well- formed external parsed entity

[78] extParsedEnt ::= TextDecl 77 ? content 43 - Char 2 * RestrictedChar 2a Char 2 *

21.6.1.33 Encoding declaration

[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 */

21.6.1.34 Notation declarations

[82] NotationDecl ::= '<!NOTATION' S 3 Name 5 S 3 ( ExternalID 75 PublicID 83 ) S? '> '

[83] PublicID ::= 'PUBLIC' S 3 PubidLiteral 12



XML in a Nutshell
XML in a Nutshell, Third Edition
ISBN: 0596007647
EAN: 2147483647
Year: 2003
Pages: 232

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net