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: [xml-dev] DTD ( From Eliotte Rust Harold's Book)



 >  Suppose I am writing a DTD to have between 4 and 6 TEAM elements for a
> DIVISION element, how do I go about specifying this ?
>  Please note - I cannot have three nor seven TEAM elements for the DIVISION
> in my Document, such a document must be forced 
>  to be treated as invalid.
> 
>  Hint : I can try to enforce the same above by grouping TEAM elements in a
> sequence, but still, I have cracked this to atleast
>  have 4 elements but not the second criterion

<!ELEMENT DIVISION ( TEAM, TEAM, TEAM, TEAM, (TEAM, TEAM?)? ) >

If you have other elements interspersed, then a DTD will explode with terms
and hide the intent.

If you use Schematron, you can go

<schema xmlns="http://www.ascc.net/xml/schematron" >
    <pattern>
        <rule context="DIVISION">
            <assert test="count(TEAM) &gt;= 4"
            >A DIVISION element should have 4, 5 or 6 TEAM elements.</assert>
            <assert test="count(TEAM) &lt;=6"
            >A DIVISION element should have 4, 5 or 6 TEAM elements.</assert>
    </pattern>
</schema> 

which will work regardless of any other elements in DIVISION.

Cheers
Rick Jelliffe