[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

re: newbie: problems computing output from variables

Subject: re: newbie: problems computing output from variables
From: Sam Griffiths <S.Griffiths@xxxxxxxxxx>
Date: Wed, 7 Feb 2001 12:25:37 -0000
sam griffiths design
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:

*XML*

<faqs>	
  <lastid>2</lastid>
 <faq>
	<id>1</id>
	<edit_id>1</edit_id> [this question has not been edited or is
re-archived]
	<question>this is a question</question> 
	<answer>this is an answer</answer>
</faq>
 <faq>
	<id>2</id>
	<edit_id>3</edit_id> [this question has been edited]
	<question>another question</question>
	<answer>another answer</answer>
</faq>
...
</faqs>

*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 !=
$edit_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:choose>
<xsl:when test="$edits">
<xsl:value-of select="$question"/><br/>
<input name="edit_id" type="hidden" value="{id}"/>
<!--</xsl:for-each>-->
</xsl:when>
</xsl:choose>
</xsl:for-each>
...
</xsl:template>

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

Thanks a lot

Sam

Interface Design
Syzygy Ltd.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.