[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?

  • From: James Clark <jjc@j...>
  • To: Rick Jelliffe <ricko@a...>
  • Date: Sat, 03 Feb 2001 10:38:59 +0700

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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.