Re: [xsl] Casting single-item sequences to atomic values

Subject: Re: [xsl] Casting single-item sequences to atomic values
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 8 Apr 2014 18:31:58 +0100
On 8 Apr 2014, at 14:42, Wendell Piez <wapiez@xxxxxxxxxxxxxxx> wrote:

> Christian,
>
> This is easy to find in the spec ... if you look at the right spec. :-)
>
> http://www.w3.org/TR/xpath-datamodel/#sequences
>
> Cheers, Wendell
>


It might also be worth reminding people WHY a singleton and a sequence of
length one are the same thing in XDM.

Consider

<book>
  <author>John</author>
</book>

Is child::author a single element, or a sequence of elements with length one?
You can't tell without a schema. Treating both the same way is part of the
"semi-structuredness" of XPath as an XML processing language. Contrast data
binding tools, which rely on a schema to decide whether author is a
single-valued or list-valued property, and cause your programs to break if the
schema changes.

Michael Kay
Saxonica

Current Thread