Re: [xsl] newbie: problems computing output from variables

Subject: Re: [xsl] newbie: problems computing output from variables
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 7 Feb 2001 12:50:47 GMT

> Xerces  tells me that it is unable to convert #BOOLEAN to a NodeList.

which is a rather exact description of the problem (compared with
typical compiler error messages)

$edits[position() &lt; 6]. 

you can only apply a filter [....] to a node list, and that produces
a current node list for which the predicate is true.

Your $edits variable (despite its name) does not contain nodes
it is a boolean (either true or false)

You have

<xsl:variable name="edits" select="id != edit_id"/>

so that select expression doesn't select any nodes, it just returns true
or false depending on whether id = edit_id. As you evaluate this in the
root template, and the child of the root is called faqs, both id and
edit_id will select an empty node set. 
for node sets a != b is true if _any_ node in a has a string value that
is not equal to any node in b. In your case, both node sets are empty
so there are no nodes not equal, so the predicate is false.

> The point of this is to display only the *x most recently edited
> questions*

<xsl:template match="/">
  select="/faqs/faq[id != edit_id][last() - position() &lt; 6]"/>

<xsl:template match="faq">


This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit

 XSL-List info and archive:

Current Thread