pXML Syntax EBNF

The following table specifies pXML's basic syntax. Extensions like attributes, namespaces etc. are not included.

The syntax is also specified as Railroad Diagrams.

NameRuleExamples
element ::=   empty_element
| non_empty_element
empty_element ::= "[" name "]"[map]
non_empty_element ::= "[" name " " value "]"[teacher Bob]
[div A [i nice] dog]
name ::= regex:
[a-zA-Z_][a-zA-Z0-9_-.]*
index
Index_12
_INDEX_12.5-a
value ::= ( text | element ) +Tree
[list]
[color orange]
All is [i [b very] well]!
text ::= character +abc
3.14
config.\["port"\]
character ::=   any Unicode character,
  except "[", "]", and "\"
| "\["
| "\]"
| "\\"
| "\u" hex hex hex hex
a
é
\[        ([)
\]        (])
\\        (\)
\u002A    (*)
hex ::= regex:
[0-9a-fA-F]
1
a
F

Note:

A pXML name must follow the same rules as an XML name. The above regex ([a-zA-Z][a-zA-Z0-9-_.]*) is a simplified version of the authoritative rules for XML names. A simple description of the rules can be found in chapter "XML Naming Rules" of XML Elements.

As can be seen from the above rules, pXML's basic grammar is very simple. This makes it easy to write a basic parser in any programming language.

A pXML document is a tree of nodes. Each node has a name, and an optional ordered list of texts (leaf nodes) and/or child-nodes (branch nodes). This simple structure allows to store any dataset of any complexity. For example, maps (key/value pairs), simple or complex configuration data, markup code (styled text), tables, databases, etc. can all be stored in pXML.