OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: Re: [relax-ng-comment] Abbreviated compact syntax (Re: Compact syntaxis not compact enough. Why?)


> > > element foo { } would be abbreviated as <foo> { }
> >
> > why not just
> >
> > foo {}
> >
>
> In my opinion it is too visually close to a reference to a named
> pattern which is just a name without any following curly braces.
> Also I think the brackets help when you are writing
> more complex name classes like for example <*> or <* - foo:*>

I don't think either of the suggested changes would be an improvement.  I
would make the following observations:

1. From my perspective, the primary goal of the compact syntax is not
compactness; the primary goal is readability.  More compact is not
necessarily better.  For me, compactness is a goal only in so far as it
assists readability.

2. There are two disadvantages to simply leaving out the element keyword (as
opposed to replacing it with some non-alphabetic symbol).

(a) It makes the syntax very difficult to parse. Consider

foo|bar|baz { ... }

You can't tell till you get to the "{" that the "foo" is an element name
rather than a reference to an pattern.  In other words, you would need
arbitrary lookahead to parse it.

(b) It means that element names that happen to be keywords would have to be
escaped.  With the current syntax, you can say

 element text { empty }

even though text is a keyword.  I think this is important, because it means
that a novice user that is using a subset of the language without
definitions/references does not have to remember the set of reserved words.

3. Replacing the keywords with some non-alphabetic symbol certainly could be
made to work.  But I don't think it would be an improvement. "@" and "<>"
don't seem to me to make a good pair.  If I am using <foo> to start an
element, then I would expect the end of the element to be written as </foo>
and I would expect attributes to be written as att="val".  "@" is reasonable
for attributes but the syntax for elements should be parallel: a single
non-alphabetic character that suggests "element".  Unfortunately, there
isn't any single character that seems suggestive to me.  One could pick
something arbitrary (! or $ or whatever), but that would make the meaning of
a schema less obvious to somebody who was unfamiliar with the syntax.

4. In real-world, non-trivial schemas, references to patterns (written using
a bare name) tend to be much more common that element patterns. (For example
in the docbook.rng that I use, there are 378 element patterns and 2866 ref
patterns).   The thing that makes a big difference to the compactness of
such schemas is the syntax for definitions/references (which is as compact
as possible in the current syntax) rather than the syntax for element
patterns.  The current syntax encourages the use of references/definitions,
which I think is a good thing.

James






[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC