Re: [XPath] Simple Mapping Operator

Mike Kay wrote:

> Why is this needed?
>
> Basically because the "for" expression is too heavyweight for the
> task. The "for" expression introduces range variables, which are
> only really needed when doing joins, and joins in XPath expressions
> are actually extremely unusual. The vast majority of "for"
> expressions actually used in XPath are not nested. By requiring
> users to use "for" expressions as the only mapping construct in the
> language, (a) they are forced to use a syntax that is unlike the
> rest of XPath, and (b) they have to switch idioms to use variables,
> instead of using the context item in the way that comes naturally -
> which is a very common source of errors.
>
> There has been some sentiment that a simple mapping operator would
> remove the need for "for" expressions in XPath entirely. I'm not
> arguing for that here (I think there is some merit in XPath being
> relationally complete). But for a language so heavily based on
> sequences, I think the simple mapping operator is really needed.

I'd add that even if 'for' expressions were retained, including a
simple mapping operator in XPath would allow those host languages that
do not need to be relationally complete or have their own mechanisms
for iteration and variable assignment to subset XPath without losing
the ability to perform operations over sequences.

In fact, given a simple mapping operator, I think it would tell a more
consistent story about the relationships between XPath, XQuery and
XSLT if XPath adopted the full FLWOR expression. XPath would then be
for querying XML documents to retrieve existing nodes and calculate
values. XQuery and XSLT would be alternative languages for
constructing node trees. XSLT could subset XPath, dropping those
expressions that involve range variables (for/some/every), since it
has other mechanisms for joins.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Thursday, 4 December 2003 10:48:46 UTC