[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: (Correction) Re: Are we losing out because of grammars?
Rick Jelliffe wrote: > From: James Clark <jjc@j...> > >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: > > <pattern> > <rule context="a"> > <assert test= > "*[1][self::b][next-sibling::c[position()=last()]] or > *[1][self::b][position()=last()]" /> > </rule> > <rule context="b[* or @*] | c[* or @*]"> > <report test="1=1" >Should be empty.</report> > </rule> > </pattern> > > 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 rules. > 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. James
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|