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

Subject: Re: Can solve the N-queens - but can't count!
From: James Clark <jjc@xxxxxxxxxx>
Date: Thu, 17 Jun 1999 19:37:56 +0700
Oren Ben-Kiki wrote:

> 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.

The distinction is between source trees and result trees.  If you do:

 <xsl:variable name="y" expr="$x"/>

then if $x is a result tree fragment, $y will be too.

> 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?

If XSLT allowed you do anything with result tree fragments that you can
do with source node sets, then you would in effect be able to do
multi-pass processing in XSLT:

<xsl:template match="/">
<xsl:variable name="pass1result">
  <xsl:apply-templates select="." mode="pass1"/>
<xsl:variable name="pass2result">
  <xsl:apply-templates select="$pass1result" mode="pass2"/>
<xsl:apply-templates select="$pass2result" mode="pass3"/>

Whilst this would be very powerful, there is concern that this would
make infeasible to create incremental, interactive implementations. 
However, XSLT is designed so that this restriction can be relaxed in the
future (ie you can extend XSLT to allow multi-pass transformations
simply by treating a result tree fragment as a node-set containing a
single root node).

> 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:
> <foo></foo>
> What am I doing wrong?

Failing to email me a proper bug report including the complete
stylesheet and source document.


 XSL-List info and archive:

Current Thread