Entry
XML: Parser: Syntax: BNF: What is a possible Backus Naur Form for XML?
Oct 20th, 2003 22:45
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 21 October 2003 - 06:30 am --------------------
XML: Parser: Syntax: BNF: What is a possible Backus Naur Form for XML?
---
Note: this will be worked out further, it is certainly a
simplification.
For the full EBNF for XML, see the link below.
---
As Backus Naur diagram:
---
+------------+
xmlprogram = -+xmlstatement+-
+------------+
xmlstatement =
+-------+ +------------+ +-------+
-(<)-+xmlbody+-(>)-++xmltext ++-(<)-(/)-+xmlname+-(>)-
+-------+ |+------------+| +-------+
|+------------+|
++xmlstatement++
|+------------+|
|+------------+|
++empty ++
+------------+
+------<------+
+-------+ |+-----------+|
xmlbody = -+xmlname+-++xmlproperty++-
+-------+ |+-----------+|
+------>------+
+-----------+
xmlname = -+xmlvariable+-
+-----------+
+-----------+
+----+ | +----+ |
xmlvariable = ++A..Z+-+ | ++A..Z+-+ |
|+----+ | | |+----+ | |
|+----+ | | |+----+ | |
--++a..z+-+-+-++a..z+-+ |
|+----+ | |+----+ +-+-
|+----+ | |+----+ |
++ _ +-+ ++ _ +-+
+----+ |+----+ |
|+----+ |
++0..9+-+
+----+
+-------+ +--------+
xmlproperty = -+xmlname+-(=)-(")-+xmlvalue+-(")--
+-------+ +--------+
+-------+
xmlvalue = -+xmltext+-
+-------+
+---------------------------------+
xmltext = -+ASCII 32..255, except '<' and '>'+-
+---------------------------------+
---
---
In Backus Naur Form:
xmlprogram = [xmlprogramheader] [xmlstatement]+
xmlprogramheader = 'to be further checked and included later, in order
keep it simple, the structure is similar to an xmlstatement, except
starting and ending with '<?', '?>', and '<!--', '-->' and '<!', '>''
xmlstatement = [xmlstatementheader] ( [xmltext] | [xmlstatement] |
[xmltextempty] ) [xmlstatementfooter]
xmlstatementheader = '<' [xmlname] [xmlparameter]* '>'
xmlname = [A-Za-z_][A-Za-z_0-9]+
xmlparameter = [xmlname] '=' '"' [xmltext] '"'
xmlstatementfooter = '</' [xmlname] '>'
xmltext = [A-Za-z0-9_!@#$%^&*()-+=?/'`~,.\|]*
xmltextempty = '' (this means that no text is present between the
header and footer tags, like in '<BOOK></BOOK>')
---
---
In words:
1. an xmlprogram:
starts with an xmlprogramheader,
followed by one or more xmlstatements.
2. where an xmlprogramheader will be handled later by me
3. where an xmlstatement:
starts with an xmlstatementheader,
followed by:
-or xmltext
-or again (a nested) xmlstatement
-or empty text
and this followed by and xmlstatementfooter.
4. where an xmlstatementheader:
starts with a '<',
followed by an xmlname,
followed by zero or more parameters,
followed by a '>'
5. where an xmlname is a variable name,
starting with abcd..z or ABCD...Z, or '_',
and possibly followed by one or more abcd..z or ABCD...Z,
01234...9, or '_'
6. where an xmlparameter:
starts with an xmlname,
followed by '=',
followed by '"',
followed by some text,
followed by '"'
7. where xmltext is most of the characters on the keyboard
(except '<' and '>')
8. where an xmlstatementfooter:
starts with a '<',
followed by an xmlname,
followed by a '>'
---
---
Internet: see also:
XML is defined by an EBNF grammar of about 80 rules
http://www.jelks.nu/XML/xmlebnf.html
---
Extensible Markup Language
http://www.w3.org/TR/REC-xml#sec-notation
----------------------------------------------------------------------