A simple namespaces proposal for iXML

Hi list,

As promised/threatened, please find below a proposal for some simple namespace support for invisible XML.  I am starting by laying out assumptions and some suggestions for technical implementation, and leaving the case for why we should be doing this separately.

I have copied the proposal to https://github.com/invisibleXML/ixml/issues/66

Principles/assumptions

• Prefixed non-terminals will represent nodes in a declared namespace.
• Un-prefixed non-terminals will represent nodes in no namespace.
• There will be no default namespace declarations; all namespace declarations shall be associated with a prefix in the grammar.
• Prefixes can be associated with at most one namespace
• Namespace associations in the grammar will not change.
• you never need to add anything to your grammar in order not to use namespaces; and you must add something to your grammar if you do want to use namespaces;
• those who have no need of namespaces in their XML never need to consider the rules for using them in ixml.

Grammar Implementation
It makes sense for me for all namespaces to be declared at the beginning of a grammar; I suggest an optional prolog:
        ixml: s, prolog?, rule+S, s.
The prolog may contain a number of namespace declarations (if we find other uses for a prolog later, those may be added here); prolog entries can be disambiguated from rules by the presence of a keyword ("xmlns") and mandatory whitespace:
      prolog: nsdecl*S
      nsdecl: "xmlns", S, @prefix, s, -["=:"], S, @nshref, -".".
      nshref: -string
The namespace refers to a namespace value nshref, which we treat as a string, and a prefix.
In order to allow colons in non-terminal names, we make the whitespace after a rule declaration = or : character mandatory:
        rule: (mark, s)?, name, s, -["=:"], S, -alts, -".".
and, of course, we need to add optional prefixes to non-terminal names:
       @name: (prefix, ":")?, namestart, namefollower*.
     -prefix: namestart, namefollower*
  -namestart: ["_"; L].
-namefollower: namestart; ["-.·‿⁀"; Nd; Mn].
The above is a suggestion as a starting point: I am sure there are likely to be some errors or areas for further consideration by the group!

Thanks,
Tom

_________________
Tomos Hillman
eXpertML Ltd
+44 7793 242058

Received on Friday, 8 April 2022 11:31:47 UTC