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 quiz: 3 elements and at least one must bepresent

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]

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