RE: creating sequences: defaults, surprises, syntax and semantics

> When I write
> 
>   ...
>   <xsl:variable name="out">
>     <xsl:choose>
>       <xsl:when test="$in='phrase'">
>         <xsl:sequence select="('span','p','div')"/>
>       </xsl:when>
>       <xsl:when test="$in='div'">
>         <xsl:sequence select="('div','p','span')"/>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:copy-of select="('baar', 'blamm')"/>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:variable>
> 
>    ...
>    <xsl:call-template name="elements">
>      <xsl:with-param name="choices" select="$out"/>
>    ..
> 
> I'd like the have a sequence assigned to the variable and send to the 
> called template, not a string. *If* I would like to turn the sequence 
> into something else, I would say so by adding an "as" attribute.
> 
> The issue lies in an area where ease of use an intuitiveness 
> of XSLT 2 
> can be improved. AFAIK a nice solution would probably involve 
> breaking 
> XSLT 1.0 backwards compatibility, but I think it would be worth it.

I agree with you that the interaction of the different options on
xsl:variable has become rather too complex for comfort.

One possibility that we might consider is that in 2.0 mode, an xsl:variable
with no "as" attribute returns the sequence as provided, and if you want to
construct a temporary tree, you do it as

<xsl:variable name="x">
  <xsl:document-node>
    <...>
  </xsl:document-node>
</xsl:variable>

In 1.0 mode, an xsl:variable with no content and no "as" attribute would
construct the document node implicitly.

There would be some surprises when the version number is changed to 2.0, for
example

<xsl:variable name="x">
  <xsl:text>Chapter</xsl:text>
  <xsl:value-of select="$num"/>
</xsl:variable>

<xsl:if test="$x = 'Chapter3'">

would produce different results with version="1.0" and version="2.0", so we
would need to look at this carefully.


> 
> 2. A question:
> 
> Can a sequence consist of numbers, strings, etc, mixed? 

Yes it can. It can even contain a mixture of nodes and atomic values.

Michael Kay

Received on Thursday, 8 May 2003 08:13:40 UTC