[xsl] An issue with XPath 2.0 sequences (Was Re: RE: Muenchian method, and keys 'n stuff)

Subject: [xsl] An issue with XPath 2.0 sequences (Was Re: RE: Muenchian method, and keys 'n stuff)
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 30 Jan 2002 11:30:24 -0800 (PST)
> > It's interesting that you can build a sequence of integers in XPath
> > 2.0 with the 'to' operator, but not a sequence of characters. For
this
> > situation, it would be really nice to be able to do:
> >
> >   <xsl:for-each select="'a' to 'z'">
> >     ...
> >   </xsl:for-each>
> >
> 
> It's often been suggested that there should be char-to-unicode and
> unicode-to-char functions, which would allow you to write
> 
> <xsl:for-each
>     select="for $i in char-to-unicode('a')
>                    to char-to-unicode('z')
>             return unicode-to-char($i)">
> ...
> </xsl:for-each>
> 
> That would be explicitly based on Unicode values; finding all the 
characters
> that are between 'a' and 'z' in your default collating sequence
sounds like
> a more difficult challenge.


This challenge is a result from the inability in XPath 2.0 to regard a
string as a sequence of characters, and this is a consequence of the
decision not to allow a sequence to have elements, which themselves are
sequences.

As can be seen, the last decision is the logical result of another 
decision to regard every simple value as a sequence consisting of one
element.

I already provided an example of a problem, which could be efficiently
solved in case we could have a sequence of sequences. This problem is
to produce simultaneously (in one pass) two sequences -- e.g. one that
contains all the elements of a sequence, which satisfy a given
predicate, and the other containing the rest.

Several people already expressed their curiosity about what was the
reason to forbid a sequence to have an element-sequence.

I think that these examples show it would be better to allow
elements-sequences and to treat simple values only as such and not as
sequences. The latter also fits better the idea of type-checking as it
gives a single value exactly one type, as opposed to two types now --
its true type and its type as a sequence.

Cheers,
Dimitre Novatchev.




__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread