5.3 Logical Structure

Prolog

The prolog of the document entity specifies if it uses external entities . The prolog also connects to the DTD:

[22]
prolog
::=
XMLDecl? Misc* (doctypedecl Misc*)?
[23]
XMLDecl
::=
'<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
[24]
VersionInfo
::=
S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
[25]
Eq
::=
S? '=' S?
[26]
VersionNum
::=
([a-zA-Z0-9_.:] | '-')+
[27]
Misc
::=
Comment | PI | S
[80]
EncodingDecl
::=
S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )
[81]
EncName
::=
[A-Za-z] ([A-Za-z0-9._] | '-')*
[32]
SDDecl
::=
S 'standalone' Eq  (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))

VersionNum currently is 1.0 . The possible EncName are predefined; the default is UTF-8 .

standalone='yes' promises that the document does not use external markup declarations which really affect the document — this is intended for processing optimization.

The Document Type Declaration is in the prolog and contains or references markup declarations which constitute the Document Type Definition as a grammar for a document.

Elements

A document contains one element which can contain further, nested elements.

[39]
element
::=
EmptyElemTag | STag content ETag
[40]
STag
::=
'<' Name (S Attribute)* S? '>'
[41]
Attribute
::=
Name Eq AttValue
[42]
ETag
::=
'</' Name S? '>'
[43]
content
::=
CharData? ((element | Reference | CDSect | PI            | Comment) CharData?)*
[44]
EmptyElemTag
::=
'<' Name (S Attribute)* S? '/>'
[14]
CharData
::=
[^<&]* - ([^<&]* ']]>' [^<&]*)

A Name ( generic identifier ) must be immediately at the beginning of a tag. It connects STag and ETag and it defines the element type in the DTD.

An Attribute Name can be specified only once.