Hi Folks, XML documents oftentimes contain a set of things – a set of books, a set of people, a set of transactions, etc. Typically, a set isn’t allowed to contain just anything, the set must satisfy some constraints. Constraints can be expressed in different ways. Perhaps one way is better than another? Perhaps one is more declarative, the other more imperative? Perhaps one is XMLish, the other not? Example: Here is an XML document containing a set (of positive even numbers):
<numbers>
…
Here are two ways to specify the set:
1. Defining properties: identify the properties that each member of the set must have. In this example, each number must have these 2 properties:
The two properties can be expressed in Schematron:
<sch:rule context="number">
2. Generate set members: specify how to generate the members of the set. The set of positive even numbers can be generated this way:
Generating the set’s members can be expressed in Schematron:
<sch:rule context="numbers">
Recap: We’ve seen two ways to specify (constrain) a set:
(a) State a property (or properties) that an object must have to qualify as a member of the set.
(b) Define a set of rules which generate its members.
Which way is better? Which is preferred? Which is more declarative? Which is more XMLish?
/Roger |