RE: [xml-dev] XPath 2.0 - how much of XQuery should it include?

> 
> Of course there's not full composability, but then neither 
> design gives you that (or at least not as I understand it). 
> In the current design, there are the duplications:
> 
>    - xsl:choose   vs. if
>    - xsl:for-each vs. for
>    - xsl:variable vs. range variables
>    - xsl:sort     vs. sort()
> 
> xsl:item would eliminate the requirement for the last two of 
> these duplications. I'm not sure what duplications it would 
> add in their place?

You are assuming we would be able to remove range variables from XPath,
which is by no means a necessary consequence of adding xsl:item. We would
probably be able to ditch sort(), though I would be reluctant to see it go:
the construct

<xsl:variable name="sorted-list">
  <xsl:for-each select="x">
    <xsl:sort select="."/>
    <xsl:item select="."/>
  </xsl:for-each>
</xsl:variable>

seems very clumsy compared with

<xsl:variable name="sorted-list" select="sort(x)"/>

We would end up with a new duplication in the area of sequence construction,
because XPath would certainly not be viable without the (x,y,z) construct.

And the more I think about using <xsl:for-each> and <xsl:choose> to do
sequence construction, the more messy it seems. For example, what does the
following mean:

<xsl:variable name="x" type="sequence">
  <xsl:item select="1"/>
  <xsl:value-of select="2"/>
  <xsl:value-of select="3"/>
</xsl:variable>

Do we really want this to create a sequence consisting of one integer and
two text nodes?

And consider:

<xsl:template name="x">
<xsl:value-of select="first-name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="last-name"/>
</xsl:template>

<xsl:variable name="y" type="sequence">
<xsl:call-template name="y"/>
</xsl:variable>

How many items are there in the sequence $y?

The more I look into this, the more difficult and confusing it seems, and
the more I feel that we've got the XSLT/XPath split just about right.

Michael Kay

Received on Thursday, 16 May 2002 01:56:32 UTC