XML
Sintaxes completas representadas por
Diagrama Sintático - Diagrama de Sintaxe
(
ver convenções
) ou
BNF
(ver
convenções
).
Diagrama Sintático - Diagrama de Sintaxe
|
Diagrama Sintático - Diagrama de Sintaxe e BNF
|
BNF
1
.
xml
xml
: prolog element Comment
2
.
prolog
prolog
: XMLDDecl? Comment (doctypedecl Comment)?
3
.
element
element
: EmptyElementTag | stag content etag
4
.
Comment
Comment
: '<!--' ('-'? Char_)* '-->'
5
.
XMLDecl
XMLDecl
: <'?'xml VersionInfo EncodingDecl? SDDecl? '?'>
6
.
doctypedecl
doctypedecl
: <'!'DOCTYPE Name ExternalID? ('[' intSubset ']')? >
7
.
EmptyElementTag
EmptyElementTag
: '<' Name Attribute* '/>'
8
.
stag
stag
: '<' Name Attribute* '>'
9
.
content
content
: CharData? ((element | Reference | CDSect | Comment) CharData?)*
10
.
VersionInfo
VersionInfo
: 'version''='("'" VersionNum "'" | '"' VersionNum '"')
11
.
EncodingDecl
EncodingDecl
: 'encoding''='('"' EncName '"' | "'" EncName "'" )
12
.
SDDecl
SDDecl
: 'standalone''='(("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
13
.
ExternalID
ExternalID
: 'SYSTEM' SystemLiteral | 'PUBLIC' PubidLiteral SystemLiteral
14
.
intSubset
intSubset
: (markupdecl | DeclSep)*
15
.
Attribute
Attribute
: Name '=' AttValue
16
.
Reference
Reference
: EntityRef | CharRef
17
.
markupdecl
markupdecl
: elementdecl | AttlistDecl | EntityDecl | NotationDecl | Comment
18
.
DeclSep
DeclSep
: PEReference | ['WFC: PE Between Declarations']
19
.
EntityRef
EntityRef
: '&' Name ';'
20
.
elementdecl
elementdecl
: '<!ELEMENT' Name contentspec '>'
21
.
AttlistDecl
AttlistDecl
: '<!ATTLIST' Name AttDef* '>'
22
.
EntityDecl
EntityDecl
: GEDecl | PEDecl
23
.
NotationDecl
NotationDecl
: '<!NOTATION' Name (ExternalID | 'PUBLIC' PubidLiteral) '>'
24
.
PEReference
PEReference
: '%' Name ';'
25
.
contentspec
contentspec
: 'EMPTY' | 'ANY' | Mixed | children
26
.
AttDef
AttDef
: Name AttType DefaultDecl
27
.
GEDecl
GEDecl
: '<!ENTITY' Name EntityDef '>'
28
.
PEDecl
PEDecl
: '<!ENTITY' '%' Name PEDef '>'
29
.
Mixed
Mixed
: '(' '#PCDATA' Name* ')*' | '(' '#PCDATA' ')'
30
.
children
children
: (choice | seq) ('?' | '*' | '+')?
31
.
AttType
AttType
: 'CDATA' | 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS' | 'NOTATION' '(' Name* ')' | '(' Nmtoken* ')'
32
.
DefaultDecl
DefaultDecl
: '#REQUIRED' | '#IMPLIED' | ('#FIXED'? AttValue)
33
.
EntityDef
EntityDef
: EntityValue | ExternalID ('NDATA' Name)?
34
.
PEDef
PEDef
: EntityValue | ExternalID
35
.
choice
choice
: '(' cp+ ')'
36
.
seq
seq
: '(' cp ( ',' cp )* ')'
37
.
EntityValue
EntityValue
: '"' ([^%&"] | PEReference | Reference)* '"'
38
.
cp
cp
: (Name | choice | seq) ('?' | '*' | '+')?
39
.
extSubset
extSubset
: TextDecl? extSubsetDecl
40
.
TextDecl
TextDecl
: '<?xml' VersionInfo? EncodingDecl '?>'
41
.
extSubsetDecl
extSubsetDecl
: ( markupdecl | conditionalSect | DeclSep)*
42
.
conditionalSect
conditionalSect
: '<![' 'INCLUDE' '[' extSubsetDecl ']]>' | '<![' 'IGNORE' '[' ignoreSectContents* ']]>'
43
.
ignoreSectContents
ignoreSectContents
: Ignore ('<![' ignoreSectContents ']]>' Ignore)*
44
.
Ignore
Ignore
: Char* '-' (Char* ('<![' | ']]>') Char*)
45
.
extParsedEnt
extParsedEnt
: TextDecl? content
46
.
symbol
symbol
: expression
47
.
CharRef
CharRef
: '&#' ['0-9']+ ';' | '' ['0-9a-fA-F']+ ';'
48
.
VersionNum
VersionNum
: '1.' ['0-9']+
49
.
EncName
EncName
: ['A-Za-z'] (['A-Za-z0-9._'] | '-')*