by Eric van der Vlist is published by O'Reilly & Associates (ISBN: 0596004214)


Compact Syntax Reference

Table of Contents

18.1. EBNF Production Reference
"""...""" - literal segmentenclosed in three double quotesLiteral segment enclosed in three quotesdoubledouble quotes
"..." - literal segmentenclosed in double quotesLiteral segment enclosed in double quotes
'''...''' - literal segmentenclosed in three single quotesLiteral segment enclosed in three single quotessinglequotes
'...' - literal segmentenclosed in single quotesLiteral segment enclosed in single quotes
(nameClass) - Container
(pattern) - Container
*-nameClass - Name class accepting any name
-nameClass - Remove a name class from another
-pattern - Remove a set of values from a data pattern
CName - Colonized names
QuotedIdentifier - Quoted identifier
Top level - Top level
assignMethod - Defines how to assign content to start and named patterns
attribute - Pattern matching an attribute
datatypeName - Datatype name
datatypeName literal - Matches a text node and a value
datatypeName param exceptPattern - data pattern
datatypes - Namespace declaration (to identify datatype libraries)
decl - Declarations
default namespace - Default namespace declaration
div - Division (in the context of a grammar)
element - Pattern matching an element
empty - Empty content
external - Reference to an external schema
grammar - Grammar pattern
grammarContent - Content of a grammar
identifier - Identifier
identifier assignMethod pattern - Named pattern definition
identifierOrKeyword - Identifier or keyword
include - Grammar merge
includeContent - Content of an include pattern
inherit - Namespace inheritance
keyword - Keywords
list - Text node split
literal - Literal
literalSegment - Literal segment
mixed - Pattern for mixed content models
name - Define a set of names that must be matched by an element or attribute
nameClass - Define a set of names that must be matched by an element or attribute
nameClass|nameClass - Choice between name classes
namespace - Namespace declaration
namespaceURILiteral - Namespace URI Literal
notAllowed - Not allowed
nsName exceptNameClass - Name class for any name in a namespace
param - Datatype parameter
parent - Reference to a named pattern from the parent grammar
pattern - Pattern
pattern&pattern - interleave pattern
pattern* - zeroOrMore pattern
pattern+ - oneOrMore pattern
pattern,pattern - pattern,pattern pattern
pattern? - optional pattern
pattern|pattern - choice pattern
start - Start of a grammar
text - Pattern matching text nodes

This reference follows the formal description of the compact syntax described as an EBNF (Extended Backus-Naur Form, a syntax that doesn't include annotation syntax) grammar. Each definition of the EBNF grammar is documented. When a definition includes a long list of alternatives (as is the case for pattern, nameClass, and literalSegment), each alternative is documented separately. The grammar from the specification has been slightly simplified to suppress definitions that were used only once; nevertheless, the meaning has been kept unchanged.

Here is the full EBNF grammar that's used as the basis for this reference:

topLevel                ::= 
decl* (
pattern|
grammarContent*)
decl                    ::= "namespace" 
identifierOrKeyword        "=" 
namespaceURILiteral
                        |"default" "namespace" [
identifierOrKeyword]       "=" 
namespaceURILiteral
                        |"datatypes" 
identifierOrKeyword        "=" 
literal
pattern                 ::= "element" 
nameClass "{" 
pattern "}"
                        |"attribute" 
nameClass "{" 
pattern "}"
                        |
pattern ("," 
pattern)+
                        |
pattern ("&" 
pattern)+
                        |
pattern ("|" 
pattern)+
                        |
pattern "?"
                        |
pattern "*"
                        |
pattern "+"
                        |"list" "{" 
pattern "}"
                        |"mixed" "{" 
pattern "}"
                        |
identifier
                        |"parent" 
identifier
                        |"empty"
                        |"text"
                        |[
datatypeName] 
literal
                        |
datatypeName ["{" 
param* "}"] [
exceptPattern]
                        |"notAllowed"
                        |"external" 
literal [
inherit]
                        |"grammar" "{" 
grammarContent* "}"
                        |"(" 
pattern ")"
param               ::= 
identifierOrKeyword "=" 
literal
exceptPattern       ::= "-" 
pattern
grammarContent      ::= 
start
                        |
define
                        |"div" "{" 
grammarContent* "}"
                        |"include" 
literal [
inherit] ["{" 
includeContent* "}"]
includeContent      ::= 
define
                        |
start
                        |"div" "{" 
includeContent* "}"
start               ::= "start" 
assignMethod 
pattern
define              ::= 
identifier 
assignMethod 
pattern
assignMethod        ::= "="
                        |"|="
                        |"&="
nameClass           ::= 
name
                        |
NCName ":*" [
exceptNameClass]
                        |"*" [
exceptNameClass]
                        |
nameClass "|" 
nameClass
                        |"(" 
nameClass ")"
name                ::= 
identifierOrKeyword
                        |
CName
exceptNameClass     ::= "-" 
nameClass
datatypeName        ::= 
CName
                        |"string"
                        |"token"
namespaceURILiteral ::= 
literal
                        |"inherit"
inherit             ::= "inherit" "=" 
identifierOrKeyword
identifierOrKeyword ::= 
identifier
                        |
keyword
identifier          ::= (
NCName - 
keyword)
                        |
quotedIdentifier
quotedIdentifier    ::= "\" 
NCName
CName               ::= 
NCName ":" 
NCName
literal             ::= 
literalSegment ("~" 
literalSegment)+
literalSegment      ::= """ (
Char - (""" 
newline))* """
                        |"'" (
Char - ("'" 
newline))* "'"
                        |""""" (["""] ["""] (
Char - """))* """""
                        |"'''" (["'"] ["'"] (
Char - "'"))* "'''"
keyword             ::= "attribute"
                        |"default"
                        |"datatypes"
                        |"div"
                        |"element"
                        |"empty"
                        |"external"
                        |"grammar"
                        |"include"
                        |"inherit"
                        |"list"
                        |"mixed"
                        |"namespace"
                        |"notAllowed"
                        |"parent"
                        |"start"
                        |"string"
                        |"text"
                        |"token"

Note that EBNF doesn't capture the restrictions applied after simplification. The simplification process and restrictions are described in detail in Chapter 15. The main restrictions are also mentioned for each element in the "Restrictions" section.


This text is released under the Free Software Foundation GFDL.