- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Fri, 12 Jul 2002 14:58:59 +0100
- To: xmlschema-dev@w3.org, "Seema Kumar" <seema_kumar@datamatics.com>
Hi Seema, > The requirement is that any of the elements defined in the complex > type below is not mandatory, but atleast one of them is required. The difficult thing here is to say that, while there can be more than one of the set, a particular element can't be repeated. You can do it with the long and tedious content model (in DTD syntax): (FirstName, LastName?, EmailId?, Telephone?, UnitNo?, StreetNo?, StreetName?, Location?, ShortDescription?, LongDescription?) | (FirstName?, LastName, EmailId?, Telephone?, UnitNo?, StreetNo?, StreetName?, Location?, ShortDescription?, LongDescription?) | (FirstName?, LastName?, EmailId, Telephone?, UnitNo?, StreetNo?, StreetName?, Location?, ShortDescription?, LongDescription?) | (FirstName?, LastName?, EmailId?, Telephone, UnitNo?, StreetNo?, StreetName?, Location?, ShortDescription?, LongDescription?) | (FirstName?, LastName?, EmailId?, Telephone?, UnitNo, StreetNo?, StreetName?, Location?, ShortDescription?, LongDescription?) | (FirstName?, LastName?, EmailId?, Telephone?, UnitNo?, StreetNo, StreetName?, Location?, ShortDescription?, LongDescription?) | (FirstName?, LastName?, EmailId?, Telephone?, UnitNo?, StreetNo?, StreetName, Location?, ShortDescription?, LongDescription?) | (FirstName?, LastName?, EmailId?, Telephone?, UnitNo?, StreetNo?, StreetName?, Location, ShortDescription?, LongDescription?) | (FirstName?, LastName?, EmailId?, Telephone?, UnitNo?, StreetNo?, StreetName?, Location?, ShortDescription, LongDescription?) | (FirstName?, LastName?, EmailId?, Telephone?, UnitNo?, StreetNo?, StreetName?, Location?, ShortDescription?, LongDescription) but obviously that's not great (especially when you have to write it with XML Schema syntax!). An alternative would be to use a looser content model, such as the one that you already have, and supplement it with a Schematron rule. With the content model you've defined already, the Schematron rule just needs to test whether there is at least one child element of those elements have the type 'HorizontalDetail'. For example, if the element HDetail has the type HorizontalDetail, you could use: <sch:rule context="HDetail"> <sch:assert test="*"> The HorizontalDetail element must have at least one child element. </sch:assert> </sch:rule> Have a look at Eddie Robertsson's description of combining Schematron with XML Schema to see how to make that work with the Topologi validator: http://www.topologi.com/public/Schtrn_XSD/Paper.html Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Friday, 12 July 2002 09:59:01 UTC