[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XQuery/XPath 2.0 Data Model - values of union types


xquery union
Hi Bob,

> A union type may ambiguously match more than one string. In section
> 5, "The values of nodes whose type is derived by union from an XML
> Schema primitive type are represented by a sequence of atomic values
> each of whose type is one of the individual types from the union.
> The union type information is lost and only the specific types of
> each individual item is retained.
>
> 1. (Nit) Shouldn't this be "...derived by union from XML Schema
> primitive types..."?

It should probably be only "derived by union". There shouldn't be any
requirement for a union type to be derived from a primitive type, or
from a built-in type.

> 2. Given the following:
>
> <element name="ambig">
>   <simpleType>
>     <union memberTypes="xs:integer xs:string"/>
>   </simpleType>
> </element>
>
> And an instance:
>
> <ambig>5</ambig>
>
> Then is the value of this node the sequence (5, "5")? If so, what is
> the reason for preserving both values? Are they used elsewhere? This
> treatment seems inconsistent with that given non-primitive types,
> like list. If not, and the value is (5) please ignore the remaining
> questions and explain what the paragraph in question really means?

The value of this node is (5). What the paragraph means is that if you
have:

<element name="ambig">
  <simpleType>
    <list>
      <simpleType>
        <union memberTypes="xs:integer xs:string"/>
      </simpleType>
    </list>
  </simpleType>
</element>

and an instance:

<ambig>5 foo 7.3</ambig>

then the value of the <ambig> element node is (5, "foo", "7.3").

> 3. If so, is this the value returned by the dm:typed-value accessor
> for the node described in 4.3.2?

The typed value is the sequence of atomic values: (5) in the first
case, (5, "foo", "7.3") in the second case.

> 4. Whether the answer is (5) or (5, "5") I would guess the dm:type
> accessor would return xs:integer and this would be the value of type
> in the data model, as this is the value consistent with validation?

No; dm:type() gives the QName of the type of the *node*, not the type
of the *value* of the node. So in both the above cases, since the
simple type of the <ambig> element is an anonymous type, it would
return an implementation-dependent unique QName. If the schema looked
like:

<element name="ambig" type="my:integer-or-string">

<simpleType name="integer-or-string">
  <union memberTypes="xs:integer xs:string"/>
</simpleType>

then dm:type() would give the QName my:integer-or-string.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.