[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (Correction) Re: Are we losing out because of grammars?
- From: James Clark <firstname.lastname@example.org>
- To: Rick Jelliffe <email@example.com>
- Date: Sat, 03 Feb 2001 10:38:59 +0700
Rick Jelliffe wrote:
> From: James Clark <firstname.lastname@example.org>
> >Let's take a really simple example:
> ><!ELEMENT a (b?, c)>
> ><!ELEMENT b (#PCDATA)>
> ><!ELEMENT c (#PCDATA)>
> If efficiency and terseness is the criteria, what about:
> <rule context="a">
> <assert test=
> "*[self::b][next-sibling::c[position()=last()]] or
> *[self::b][position()=last()]" />
> <rule context="b[* or @*] | c[* or @*]">
> <report test="1=1" >Should be empty.</report>
> This has 5 functioning elements compared to TREX's 6.
And the DTD has no elements at all. So what? The complexity is all in
the XPath expression.
> It only require
> looking at the first child. (This is an example of elaborating each path,
> which is nasty for larger rules.) But it is not particularly the way I'd
> envision people will use Schematron.
You've just proved my point. Your solution doesn't work. Just as
x[position()=1] selects the first x element, so x[position()=last()]
selects the last x element; it does not test whether the x element is
the last child. Some very simple grammrs are awkward and error-prone to
express using path-based rules (the converse is also true).
> But lets try a different example, quid pro quo.
But I've never argued that path-based rule systems are inferior to
grammars. As I said at the beginning of my last message I think they're
a valuable complement to grammars, and for *some* problems they're a
better solution than grammars. All I'm claiming is that there are also
some problems for which grammars are a better solution than path-based
> Oh, it is no crusade against grammars. My point all along has been that
> there has never been any discussion which establishes grammars are best or
> don't cause more problems (for people implementing ad hoc editing systems
> for example) than they solve.
Why does one kind of schema have to be better than another? It's as
pointless as arguing whether hammers are better than saws. It depends
what problem you are trying to solve.
Grammars are better that rule-based systems for some things. Rule-based
systems are better than grammars for other things. If something can be
expressed simply using a grammar, it's probably a good idea to use a
grammar, because, amongst other reasons, it can be implemented very
efficiently. If it can't be expressed simply using a grammar, then use
a rule-based system.