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

Re: XML Schema quiz: 3 elements and at least one must bepresen

  • From: Rick Jelliffe <rjelliffe@a...>
  • To: xml-dev@l...
  • Date: Fri, 15 Aug 2008 12:22:38 +1000

Re:  XML Schema quiz: 3 elements and at least one must bepresen
I once had a variation on this: it was for new reports where each 
document had to have elements for <what>, <where>, <when>, <who> (and 
<how>), which a journalism professor was teaching as the essential 
elements that every professional story needed to provided.

So the constraints: five elements, where the document needed to have at 
least one of each in any order. The killer? The elements could be 
anywhere in the news report.

Obviously Schematron can do this trivially

  <rule context="/">
      <assert test="//what">A document should have at least one what 
      <assert test="//where">A document should have at least one where 
      <assert test="//when">A document should have at least one when 
      <assert test="//who">A document should have at least one who </assert>
      <assert test="//how">A document should have at least one how</assert>

but it is not something that grammars (or, at least, grammars with 
non-path particles) can do.

Even in the case of XSD 1.1 assertions, which are a great addition 
(perhaps in the way that a cheesecake is great after a 50 course meal of 
crackers)  it is difficult, because these are not constraints that 
belong to types. They are constraints of the document of a class rather 
than of any elements: so in XSD you would have to artificially tie  
these to, say, a top-level element. In XSD it cannot be expressed as a 
pattern that exists in isolation from other particulars of the document. 
The pattern concept is more general than the type concept.

Rick Jelliffe

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


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.