Subject: Re: Can solve the N-queens - but can't count!
From: James Clark <jjc@xxxxxxxxxx>
Date: Thu, 17 Jun 1999 17:03:08 +0700
|
Oren Ben-Kiki wrote:
> Is this legal today? James clark wrote:
>
> >You cannot use a variable as a location step, but the above examples are
> >valid. See production [18] PathExpr.
>
> And yes, PathExpr does allow "$Variable" as the first thing in a path
> (section 6.2.1, "PrimaryExpr") However, giving XT the above or even:
>
> <xsl:copy-of select="$var/a"/>
>
> Causes the error:
>
> DID NOT EXPECT cannot convert to node-set
$var has to be a node-set. The WD says this in 4th paragraph of section
6.2.2.
> And there's no word in the limitation sections about this. Given James is
> also the editor of the draft and the implementer of XT, I find the whole
> combination somewhat confusing. Examining the draft, I find that the
> introduction to section 6 states:
This is not relevant. "Patterns" are the things that occur in match
attributes in xsl:template.
> "The only operations that can be performed on a result tree fragment are to
> convert it to a string or a boolean. In particular, it is not permitted to
> use the /, //, and [] on result tree fragments.
>
> Expressions can only return values of type result tree fragment by
> referencing variables of type result tree fragment or calling extension
> functions that return a result tree fragment."
>
> However it isn't defined what a "result fragment" is (there's an editorial
> note to fix that). I _assumed_ that a variable holding a node set would
> qualify, in which case the code above is invalid and XT is correct.
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.
James
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|