Re: Can solve the N-queens - but can't count!

Subject: Re: Can solve the N-queens - but can't count!
From: "Oren Ben-Kiki" <oren@xxxxxxxxxxxxx>
Date: Thu, 17 Jun 1999 12:41:52 +0200
James Clark <jjc@xxxxxxxxxx> wrote:

>The value of a variable is a result tree fragment if you define the
>variable it using xsl:variable without an "expr" attribute.  For
>example, if you do:
> <xsl:variable name="x"><xsl:apply-templates/></xsl:variable>
>the $x refers to a result tree fragment, so doing
>  <xsl:copy-of select="$x/a"/>
>is an error.
>On the other hand if you do:
>  <xsl:variable name="x" expr="//foo"/>
>then $x refers to a node-set, so you can legally do
>  <xsl:copy-of select="$x/a"/>
>See the third paragraph of Section 13.

Oh! I missed that. So if I create a variable containing a 'foo' element, it
matters _how_ I created it - if it was using an expression, it is a node
set, otherwise it is a result tree fragment. And that makes a huge
difference in what can be done to it, even though the contents is "the
same". I must say I find this to be confusing - from a stylesheet writer's
point of view, why should it matter?

BTW, I tried writing:

<xsl:variable name="x" expr="//foo"/>
<xsl:copy-of select="$x"/>

And the obvious variants, but kept getting empty results (using XT
1999-05-14). I expected to get:


What am I doing wrong?

Have fun,

    Oren Ben-Kiki

 XSL-List info and archive:

Current Thread