[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Are we losing out because of grammars?

  • From: James Clark <jjc@j...>
  • To: Rick Jelliffe <ricko@a...>
  • Date: Fri, 02 Feb 2001 15:01:53 +0700

b c because
Whilst I think the approach used by Schematron is an valuable complement
to grammar based schemas (obviously I'm personally delighted to see
XPath getting used for validation), I really find it very hard to take
seriously the idea that the time has come to completely discard grammars
in favour of path-based rule systems.

Let's take a really simple example:

<!ELEMENT a (b?, c)>

or as a TREX pattern:

<element name="a">
    <element name="b">
  <element name="c">

Let's try and write a Schematron schema that accepts exactly this
grammar.  I'm no Schematron expert, but here's my naive attempt (actual
text of error messages omitted):

   <rule context="a">
     <assert test="count(c)">...</assert>
     <assert test="count(*) = count(b|c)">...</assert>
     <assert test="count(c) &lt;= 1">...</assert>
     <assert test="count(b) &lt;= 1">...</assert>
     <assert test="b[preceding-sibling::c]">...</assert>
     <assert test="@*">...</assert>
   <rule context="b|c">
     <assert test="*">...</assert>
     <assert test="@*">...</assert>

I do not understand how this can possibly be considered an improvement
over the grammar.  For this case, the Schematron schema seems much
harder to write. Even for this trivial case, it's not obvious whether it
accurately captures my intent. Moreover, any current implementation is
likely to be much less efficient than the corresponding grammar based
approach; it will need random access to the instance document, and will
make probably about 6 or 7 passes over the children of the "a" element
in order to validate it.  By constrast a grammar-based implementation
can do it in a single, streaming pass.  Maybe some future Schematron
implementation will be able to optimize it, but that's just speculation,
whereas efficient implementation of grammars is well-established.

It seems self-evident to me that both grammars and path-based rule
systems have their place.  Some problems can be solved most conveniently
with just grammars, some most conveniently with just path-based rule
systems and some most comveniently with a combination.  Can't we just
leave it at that?  What is the point of this crusade against grammars?



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.
First Name
Last Name
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.