[XSL-LIST Mailing List Archive Home]
RE: [xsl] Looking for a shorter mapping expression
Subject: RE: [xsl] Looking for a shorter mapping expression|
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 5 Dec 2004 21:40:32 -0000
> Because, according to the XPath 2.0 spec:
> "only the last step in a path is allowed to return a sequence
> of atomic values."
> Even the last E2 in a path expression should evaluate either to a
> sequence of nodes or a sequence of atomic values, but not a mixture of
> the two... I find this unreasonably restrictive and wonder why it was
> decided so.
Until the most recent draft there was no way of mapping an expression over a
sequence without using a range variable: the "for $x in $s return f($x)"
In the most recent draft the rules for "/" were relaxed to allow constructs
such as $seq/name(): in general for the expression E1/E2, E1 must return a
sequence of nodes and E2 must return a homogenous sequence, either atomic
values or nodes.
Some of us argued instead for a different operator, say !, in which E1!E2
would perform a general mapping, the equivalent of "for . in E1 return E2".
Note that this is not the same as the "/" operator in the case of nodes,
because it doesn't return the results in document order or eliminate
duplicates. However, there has been strong opposition to the introduction of
a second operator on the grounds that users wouldn't understand the
difference from "/" and that it doesn't add any new functionality over what
can be achieved with "for" expressions.
The reason for restricting the rhs of "/" to be homogenous is that this is
the only reasonable way you can overload the operator to deliver results in
document order in the case of nodes, or retaining the input order in the
case of atomic values.
There are various reasons for retaining the restriction on the lhs to
consist of nodes. One is that it's easier to get a small change through a
committee than a big change. Another is that some people cannot stomach the
idea that the value of the expression 1/2 should be 2.