[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: modelling the business rule "at least one of the eleme
(resent) XSD provides a content type <ALL> which does what you need, I think. If you wanted the constraint that you could have more than one of each, but at least one of each, you would be looking at a really nasty content model, something like the following: (a+, (b, (a, (a |b)*)?, c) | (b, (a |b)*)?, c) | c ) | (c, (a, (a |c)*)?, b) | (c, (a |c)*)?, b) | b )) | (b+, (a, (a, (a |b)*)?, c) | (b, (a |b)*)?, c) | c ) | (c, (b, (b |c)*)?, a) | (c, (b |c)*)?, a) | a )) | (c+, (a, (a, (a |c)*)?, b) | (b, (a |c)*)?, b) | b ) | (b, (b, (b |c)*)?, a) | (c, (b |c)*)?, a) | a )), (a | b | c)* which would take about 125 XSD elements, I think. I think XSD 1.1 improves ALL to cope with this situation better. Cheers Rick Jelliffe N.B. Using Schematron, you would say for the ALL case <rule context="parent"> <assert test="count(a)=1">Parent must have one child a</assert> <assert test="count(b)=1">Parent must have one child b</assert> <assert test="count(c)=1">Parent must have one child c</assert> <assert test="count(*) = count(a) + count(b) + count(c)"> The parent can only contain a, b and c elements </assert> </rule> And the equivalent Schematron schema for the 125 element XSD rule is <rule context="parent"> <assert test="count(a) > 0">Parent must have at least one child a</assert> <assert test="count(b) > 0">Parent must have at least one child b</assert> <assert test="count(c) > 0">Parent must have at least one child c</assert> <assert test="count(*) = count(a) + count(b) + count(c)"> The parent can only contain a, b and c elements </assert> </rule> 125 versus 5...
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|