[Home] [By Thread] [By Date] [Recent Entries]

Subject: Casting single-item sequences to atomic values
From: Christian Roth <roth@xxxxxxxxxxxxxx>
Date: Tue, 8 Apr 2014 02:31:49 +0200
Hi,

why is

  (1) cast as xs:integer == 1

Or is it?

I hit upon this while trying to understand why this works:

  subsequence( ('a','b'), (1), 1)

subsequence() expects an xs:double as its second parameter, but not a
single-item _sequence_ of xs:double's. Because it works, "(1) cast as
xs:double" must be equivalent to "1 cast as xs:double", and therefore "(1) =
1".

Why I got that much confused is my following thinking on the description of
"cast" at <http://www.w3.org/TR/xpath20/#id-cast>.

It says:

> 1. Atomization is performed on the input expression.

With fn:data( (1) ) returning the sequence of atomized values of each of its
input sequence's members, this IMO yields (1).

> 2. If the result of atomization is a sequence of more than one atomic
value

Does not apply.

> 3. If the result of atomization is an empty sequence: 

Does not apply.

> 4. If the result of atomization is a single atomic value

Also does not apply in my thinking, as I get a _sequence_ of a single atomic
value. There's no step that tackles the case where the result of atomization
is a sequence of a single atomic value.

Therefore, I guess that a single-atomic-valued-item sequence is the same (or
equivalent?) as its single atomic member. I vaguely remember reading that long
time ago somewhere in the spec, but cannot find it now. Can someone please
point me to the relevant section? Thanks!

Regards
Christian

Current Thread
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member