[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Looking for a shorter mapping expression
> Because, according to the XPath 2.0 spec: > > "only the last step in a path is allowed to return a sequence > of atomic values." > > http://www.w3.org/TR/xpath20/#id-path-expressions > > 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)" construct. 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. Michael Kay http://www.saxonica.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|