- From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
- Date: Wed, 1 Jul 2009 17:16:02 -0600
- To: "Costello, Roger L." <costello@mitre.org>
- Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
On 1 Jul 2009, at 14:22 , Costello, Roger L. wrote: > > Hi Folks, > > Suppose that several <alternative> elements apply. Which one will be > used? > > Example: the below <Beverage> element has two <alternative> > elements. If the value of its current-time attribute is 08:00:00 > then both <alternative> elements apply. Which one will be used? > > <xs:element name="Beverage" type="BeverageType"> > <xs:alternative test="@current-time le '12:00:00'" > type="MorningBeverage" /> > <xs:alternative test="@current-time le '09:00:00'" > type="EarlyMorningBeverage" /> > </xs:element> Short answer: the type table selects the type given by the first alternative with a test which evaluates to true. In many cases, this determines the type definition used to validate the element, but it can be overridden by user-stipulated and instance-specified types. Longer answer, with details: The validation rule Schema Validity Assessment in section 3.3.4.6 says among other things that elements are validated (if they are not skipped) against their governing element declaration and governing type definition. So your question amounts to asking "How is the governing type definition determined, when conditional type assignment is used?" The definition of 'governing type definition' in section 3.3.4.6 specifies how the governing type of an element is identified. Conditional type assignment comes into the rule by affecting the choice of the 'selected type definition' (which is the governing type definition unless either the user has specified a different type when invoking the validator, or the instance specifies a type using xsi:type). The definition of 'selected type definition' in section 3.3.4.1 says that if a type table appears in the relevant element declaration, the selected type definition is the type definition 'conditionally selected' by the type table. The definition of 'conditional selection' in the next paragraph says in part: The {test} expressions in T's {alternatives} are evaluated, in order, until one of the Type Alternatives ·successfully selects· a type definition for E, or until all have been tried without success. If any Type Alternative ·successfully selects· a type definition, none of the following Type Alternatives are tried. I hope this helps. Michael Sperberg-McQueen -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net ****************************************************************
Received on Wednesday, 1 July 2009 23:16:43 UTC