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

Subject: re: [xsl] newbie: problems computing output from variables
From: Sam Griffiths <S.Griffiths@xxxxxxxxxx>
Date: Wed, 7 Feb 2001 12:25:37 -0000
Hi - I hope you've got time to take a look at this one - it's got to the
banging head against brick wall stage.

I'm on the final leg of a FAQ 'site' implemented through xml/xsl. Things
have started to get a bit tricky when I've tried to further compute data
from an existing variable.

The xsl I'm using is obviously wide of the mark - I've been messing around
for too long without it working. I have been looking at Mike Kay's section
on computational stylesheets and the answers lies therein I'm sure but  I
can't see it. (I'm coming at xsl/xml from a web design background which
probably explains a lot!!)

My XML is:


	<edit_id>1</edit_id> [this question has not been edited or is
	<question>this is a question</question> 
	<answer>this is an answer</answer>
	<edit_id>3</edit_id> [this question has been edited]
	<question>another question</question>
	<answer>another answer</answer>

*Note that where edit_id = id+1  the question has been edited. (Edited
questions are formatted differently. Where a previously edited question has
been archived, the edit_id is equalised with id).


I have been able to select edited instances of $question with: test="$id !=

(so var edits  =  id != edit_id)


The problem is that I need to select the value of $question where:
$edits[position() &lt; 6]. 

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

The point of this is to display only the *x most recently edited questions*
on the list and archive the older ones automatically - rather than using a
separate 'archive' stylesheet (which relies on the administrator making a
decision to prevent the list getting cluttered).

My xsl (fumblings) are:

<xsl:template match="/">
<xsl:variable name="edits" select="id != edit_id"/>
<xsl:variable name="editvase" select="$edits[position() &lt; 6]"/>
<xsl:for-each select="/faqs/faq">
<xsl:when test="$edits">
<xsl:value-of select="$question"/><br/>
<input name="edit_id" type="hidden" value="{id}"/>

Any help would be much appreciated - especially concerning the principle
underlying my mistake - outputting boolean rather than nodesets...

Thanks a lot


Interface Design
Syzygy Ltd.

 XSL-List info and archive:

Current Thread