OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: constraints - odd question



 From: "Simon St.Laurent" <simonstl@simonstl.com>

> Suppose I want to create a preferences or properties file where the
> names of the elements correspond to the names of the properties
> involved.  I'm not concerned with validation in the sense that certain
> elements (it's all elements) must be present in a certain order, but
> there may be a different kind of validation needed.
>
> I want to make certain that no elements have the same names as their
> siblings.  Duplication of a property name will lead to overwriting, and
> they want a simple way to warn readers that the duplication has occurred
> before loading the properties file into their particular environment.

This is very simple to do in W3C XML Schema schematas. You can use
an <all> group, if all the elements are required.

If not all the properties are required, in Schematron you can use the
following :
<pattern>
  <rule context="x">
        <report test="count(prop1) &gt; 1"
            >There should not be more than one prop1 in an x</report>
        <report test="count(prop2) &gt; 1"
            >There should not be more than one prop2 in an x</report>
        <report test="count(prop2) &gt; 1"
            >There should not be more than one prop2 in an x</report>
   </rule>
</pattern>

If all the properties are required, then
<pattern>
  <rule context="x">
        <assert test="count(prop1) = 1"
            >There should be one prop1 in an x</assert>
        <assert test="count(prop2) = 1"
            >There should be one prop2 in an x</assert>
        <assert test="count(prop2) = 1"
            >There should be one prop2 in an x</assert>
   </rule>
</pattern>

You might also add the following rules to close the content model

  <rule context="x/prop1 | x/prop2 | x:prop3">
        <assert test="true()"><name/> is allowed</assert>
  </rule>
  <rule context="x/*">
        <report test="true()"><name/> is not allowed</report>
  </rule>

Cheers
Rick Jelliffe