XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] XML Schema 1.0 and Relax NG Only Partially SupportContext-Free Grammars

On Wed, 2014-01-01 at 17:39 +0000, Costello, Roger L. wrote:
> Hi Folks,
> 
> Did you know that neither XML Schema 1.0 nor Relax NG has the power to
> express this very simple grammar:
> 
> 	The content of BookStore shall be N Book elements
> 	followed by N Magazine elements.

For XSD 1.1 maybe you could add an assertion on the BookStore element,
perhaps, that count(book) eq count(Magazine) ?

A more natural XML method might be to give each book element an id and
each magazine an idref, depending on exactly why you want the numbers to
be the same.

> Neither XML Schema 1.0 nor Relax NG can express that basic context-free grammar. 
> 
> That's sad.

No, it's not sad. It's easy to come up with fake use cases that can't be
satisfied by pretty much any given formal system.

The trade-off is in clarity.

A simpler grammar,
    A sock drawer shall contain a non-prime number of clean socks
is also pretty hard to represent...

If you have a schema language that can do that (without already having
an IsPrime() functionality built-in) then you've probably got something
closer to a programming language or to a mathematical reasoning system,
at which point the set of users who can understand and make use of it
may not have a large intersection with the set of users who need
business-level contract-style validation.

You could also say,
  The number of pairs of socks in the sock drawer shall be at least
  two more than the number of days to laundry day, which is Saturday
  except when that falls on a public holiday and the laundry is closed,
  in which case it is the following Monday.

The answer is that this belongs in a layer above the schema validation;
the schema processor's job is to ensure that the sock drawer contains
only socks and paired socks, not shirts, buildings, planets, beer or
large pieces of stale chocolate. Making sure that there's a pair of
argyle dress socks available for Sunday is an application-layer task,
although one could implement that with a custom declarative rule-based
language and an interpreter, of course.

Best,

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml



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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS