Search code examples
xmlw3c

First rule of a "Well-Formed XML Document"


This is the first rule of the XML specification.

[1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )

I understand the first part: a document contains a prolog, an element and optional Misc-items.

But I do not understand the part starting with the hyphen. What does this mean? Can anybody give an example for a document containing such thing?


Solution

  • In Extended Backus-Naur Form,

    A - B
    

    matches any string that matches A but does not match B.

    Therefore, an XML document,

    [1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )

    must match the first part ( prolog element Misc* ) without matching the second part ( Char* RestrictedChar Char* ) or, in short...

    An XML document must not include any restricted characters.