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: DTD Entity



From: jcowan@reutershealth.com <jcowan@reutershealth.com>

>Richard Knapp scripsit:
>
>> We are working on DTD with the following requirement:
>>
>> - Base element consists of Child elements First, Second, Third, and
Fourth.
>> - First must appear under Base.
>> - Second, Third, and Fourth may appear zero or one time.
>> - Order is not important for elements Second, Third, and Fourth.

In Schematron, you can express that like this

<rule context="Base">
    <assert test="count(*)=count(First) + count(Second) + count(Third) +
count(Fourth)"
    >Base element consists of Child elements First, Second, Third, and
Fourth</assert>
    <assert test="count(Base)=1"
    >First must appear under Base.</assert>
    <assert test="count(Second) &lt; 2 and count(Third) &lt; 2 and
count(Fourth) &lt; 2"
    >Second, Third, and Fourth may appear zero or one time</assert>
    <assert test="*[1]/self::Base"
    >Order is not important for elements Second, Third, and Fourth.</assert>
</assert>

Note that there is a one-to-one correspondence between the original text
specification
the assertions' statements.  This is common with Schematron schemas.
(However, it is an interesting question whether, just because it is easy to
write Schematron schemas from informal/partial specs, such specs are also
easier to read by third parties.
Of course, there are consiseness issues too, when thinking of readability,
however that really is a notation issue of XML versus DTD syntax versus some
mixture.)

Note also that the process of finding a test to implements the statement
also sheds
light on the statement, allowing it to be refined: in this case that "First
must appear
under Base" means that First is a required element that is no repeating (it
seems).
In the Schematron schema, there is a clear separation from the requirements
(the text
statements) and the implementation (the test attributes).

(For anyone interested, Schematron is a free software language and toolkit
for programmers at http://www.ascc.net/xml/schematron  )

Cheers
Rick Jelliffe