Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [XML Schema 1.1] Multiple elements apply ... which

From: "C. M. Sperberg-McQueen" <cmsmcq@-------------.--->
To: "Costello, Roger L." <costello@-----.--->
Date: 7/1/2009 11:17:00 PM
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
****************************************************************







transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent