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

re - newbie question - <xsl: when test

Subject: re - newbie question - <xsl: when test
From: Sam Griffiths <S.Griffiths@xxxxxxxxxx>
Date: Thu, 25 Jan 2001 16:26:45 -0000
sam griffiths
Hello there, apologies in advance if this question has an obvious answer! I
don't usually rush to use this  list. 

I am working on a simple FAQ programme that uses xsl and xml to allow a user
to add (and edit) questions to the list (by updating the original source xml
file). 

I want to differentiate between the first five <faq>s and the rest so I can
add appropriate formatting to distinguish between two groups of questions on
a web page (recent and previous).

The xsl below only selects the *most* recent question - which is equivalent
to <lastid>. 

I'm looking for a way to express: $lastid = a range of id values [the higest
five values of this element.

Each time a user submits a question - it is given a 'new' id (previous
lastid+1) and the <lastid> element is updated correspondingly. 

I've been trying to use the position() command to achieve this - but to no
effect.

The code is:

*XML*

<faqs>	
  <lastid>2</lastid>
 <faq>
	<id>1</id>
	<question>this is a question</question>
	<answer>this is an answer</answer>
</faq>
 <faq>
	<id>2</id>
	<question>another question</question>
	<answer>another answer</answer>
</faq>
...
</faqs>


*XSL*

<xsl:param name="lastid" select="/faqs/lastid"/>
<xsl:param name="id"/>

....

<xsl:for-each select="/faqs/faq">
<xsl:sort select="id" order="descending"/>
<xsl:choose>
<xsl:when test="id=$lastid">
	<xsl:element name="A">
		<xsl:attribute name="href">#q<xsl:value-of
select="id"/></xsl:attribute>
		<font color="red"><xsl:value-of select="question"/></font>
	</xsl:element><br/>
</xsl:when>
</xsl:choose>
</xsl:for-each>

....

Any help would be much appreciated.

Thanks

Sam Griffiths

Interface Developer
Syzygy Ltd.
s.griffiths@xxxxxxxxxx

 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.