Require somewhere

From W3C Wiki
Jump to: navigation, search

Require somewhere (a co-constraint use case)

Require that a particular set of elements must occur somewhere among the descendants of a particular element, without requiring that they be in a particular location.

source: Fabio Vitali


Other use cases: Co-constraint Use Cases

Description

   A contract is just a text document with some hierarchy and typographical
   styles. Yet, in a correct contract, some elements must appear, such as the
   name and identification code of the parties, the start and end date of the
   contract, the sum being promised, the relevant court in case of discussions,
   and so on. Lawyers do NOT appreciate being forced to put these elements in any
   pre-defined position, and redundant specification of this information (e.g.,
   within the text and separately within the header) has provided lots of
   problems in precision, accountability and consistency. Solution is require
   somewhere: these elements may appear anywhere in the text, but they must
   appear. 

Analysis

(Add your analysis here; see your name in pixels!)

PVB

... am I correct in thinking that relaxed all will handle this?

Possible solutions

Relax NG

Schematron

Check clause

One possible solution is to put the following annotation on some element which is required to contain all of the information indicated.

  <xsd:annotation><xsd:appinfo><sch:pattern><sch:rule>
     <sch:assert test="count(//buyer) > 0">
      The contract must say who the buyer is.
     </sch:assert>
     <sch:assert test="count(//buyer-id | //buyer/@id) > 0">
      The contract must give the identification number for the buyer.
     </sch:assert>
     <sch:assert test="count(//seller) > 0">
      The contract must say who the seller is.
     </sch:assert>
     <sch:assert test="count(//seller-id | //seller/@id) > 0">
      The contract must give an identification number for the seller.
     </sch:assert>
     <sch:assert test="count(//binding-jurisdiction) = 1">
      The contract must indicate the jurisdiction whose laws will
      govern the resolution of any disputes over the contract.
     </sch:assert>
     <sch:assert test="count(//severability | //nonseverability) = 1">
      The contract must have a clause indicating whether its
      provisions are severable or not.
     </sch:assert>
     <sch:assert test="count(//start-date) = 1 and count(//end-date) = 1">
      The contract must have a clause indicating whether its
      provisions are severable or not.
     </sch:assert>
    </sch:rule></sch:pattern></xsd:appinfo></xsd:annotation>

Sometimes the information can be given in either of two ways, as illustrated here by the id-number clauses.

SchemaPath

Conditional Type