Browsable XML Grammar

CC-BY

Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: xmlware/xml/zhang-cordy/extracted
Source used for this grammar: Hongyu Zhang, James R. Cordy, XML 1.0 (Second edition) Grammar, and Well-formedness Checker, August 2001 [TXL Grammars]

Summary

Syntax

program ::=
	prolog element
prolog ::=
	dtd_body
dtd_body ::=
	misc* doctypedecl?
misc ::=
	comment
	pi
	space
	newline
doctypedecl ::=
	"<!DOCTYPE" spaces name spaces sp_external_id? spaces declbody? spaces ">" spaces
declbody ::=
	"[" decl* "]"
literal ::=
	charlit
	stringlit
pi ::=
	"<?" pitarget sub1_pi? "?>"
pitarget ::=
	name
sub1_pi ::=
	spaces token
sub2_pi ::=
	token "?>" token
sp_external_id ::=
	spaces external_id
external_id ::=
	exid_sys
	exid_pub
exid_sys ::=
	"SYSTEM" spaces literal
exid_pub ::=
	"PUBLIC" spaces literal spaces literal
decl ::=
	markupdecl
	"%" name ";"
	spaces
markupdecl ::=
	elementdecl
	attlistdecl
	entitydecl
	notationdecl
	pi
	comment
elementdecl ::=
	"<!ELEMENT" spaces name spaces contentspec spaces ">" spaces
contentspec ::=
	"EMPTY"
	"ANY"
	mixed
	children
children ::=
	children_body repetition?
repetition ::=
	"?"
	"*"
	"+"
children_body ::=
	choice
	seq
choice ::=
	"(" spaces cp choice_item choice_item* spaces ")"
choice_item ::=
	spaces "|" spaces cp
cp ::=
	cp_body repetition?
cp_body ::=
	name
	choice
	seq
seq ::=
	"(" spaces cp more_cps* spaces ")"
more_cps ::=
	spaces "," spaces cp
mixed ::=
	pcdata_or_name
	pcdata
pcdata_or_name ::=
	"(" spaces "#PCDATA" more_names* spaces ")*"
more_names ::=
	spaces "|" spaces name
pcdata ::=
	"(" spaces "#PCDATA" spaces ")"
attlistdecl ::=
	"<!ATTLIST" spaces name attdef* spaces ">" spaces
attdef ::=
	spaces name spaces atttype spaces defaultdecl
atttype ::=
	stringtype
	tokenizedtype
	enumeratedtype
stringtype ::=
	"CDATA"
tokenizedtype ::=
	"ID"
	"IDREF"
	"IDREFS"
	"ENTITY"
	"ENTITIES"
	"NMTOKEN"
	"NMTOKENS"
enumeratedtype ::=
	notationtype
	enumeration
notationtype ::=
	"NOTATION" spaces "(" spaces name more_names* spaces ")"
enumeration ::=
	"(" spaces nmtoken more_nmtokens* spaces ")"
nmtoken ::=
	name
	dname
more_nmtokens ::=
	spaces "|" spaces nmtoken
defaultdecl ::=
	"#REQUIRED"
	"#IMPLIED"
	fixed? attvalue
fixed ::=
	"#FIXED" spaces
attvalue ::=
	stringlit
	charlit
	longstringlit
	longcharlit
longstringlit ::=
	""" not_dquote* """
not_dquote ::=
	token
longcharlit ::=
	"'" not_quote* "'"
not_quote ::=
	token
entitydecl ::=
	gedecl
	pedecl
gedecl ::=
	"<!ENTITY" spaces name spaces entitydef spaces ">" spaces
pedecl ::=
	"<!ENTITY" spaces "%" spaces name spaces pedef spaces ">" spaces
entitydef ::=
	entityvalue
	external_id ndatadecl?
pedef ::=
	entityvalue
	external_id
ndatadecl ::=
	spaces "NDATA" spaces name
entityvalue ::=
	charlit
	stringlit
	longstringlit
	longcharlit
notationdecl ::=
	"<!NOTATION" spaces name spaces exid_or_pubid spaces ">" spaces
exid_or_pubid ::=
	external_id
	"PUBLIC" spaces literal
spaces ::=
	space_or_newline*
space_or_newline ::=
	space
	newline
element ::=
	empty_elem_tag spaces
	tag_content spaces
tag_content ::=
	stag IN content EX etag
empty_elem_tag ::=
	"<" name spaces attribute* "/>"
attribute ::=
	spaces name "=" attvalue spaces
stag ::=
	"<" name spaces attribute* ">"
content ::=
	spaces chardata* spaces sub1_content* spaces
sub1_content ::=
	spaces sub2_content spaces chardata* spaces
sub2_content ::=
	element
	reference
	cdsect
	pi
	comment
	regexp
chardata ::=
	token
etag ::=
	"</" name spaces ">"
cdata ::=
	token
	comment
cdend ::=
	"]]>"
reference ::=
	"&" name ";"
	charref
cdsect ::=
	"<![CDATA[" cdata* cdend

GrammarLabMaintained by Dr. Vadim Zaytsev a.k.a. @grammarware. Last updated in September 2015. []