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

preceding-sibling reversed ?

Subject: preceding-sibling reversed ?
From: "Bjorn Boxstart" <boxstart@xxxxxxxx>
Date: Thu, 29 Aug 2002 12:13:22 +0200
preceding sibling back next
Hello,

I created in an XSL-T stylesheet a variable that contains presentation
slides. Each of the slides is a '<div>' element with a 'class' attribute
with the value 'slide' and all these elements have and 'id' attribute with a
unique value. All slides exist in the same level in the hierarchy of the
document.

I wanted to add a 'previous' and 'next' button to each slide that (off
course) links to the previous and next slide in the presentation.

to be able to create the link to the next slide, I used the following lines:

<a>
	<xsl:attribute name="href">
		#<xsl:value-of select="following-sibling::div[@class = 'slide']/@id"/>
	</xsl:attribute>
	<img src="images/icons/next.gif" border="0"/>
</a>

This works perfect, however for the previous slide I wanted to use:

<a>
	<xsl:attribute name="href">
		#<xsl:value-of select="preceding-sibling::div[@class = 'slide']/@id"/>
	</xsl:attribute>
	<img src="images/icons/back.gif" border="0"/>
</a>

This always results in a link to the first slide (msxml). A bell started to
ring and I thought that the listing of the elements probabley would be
reversed, so I tried the following:

<a>
	<xsl:variable name="pos" select="position()" />
	<xsl:attribute name="href">
		#<xsl:value-of select="preceding-sibling::div[@class = 'slide' and
position() = $pos -1]/@id"/>
	</xsl:attribute>
	<img src="images/icons/back.gif" border="0"/>
</a>

This also results in a link to the first slide. Now I have the following
that works fine, but I don't really understand why! Can anybody please
explain me this?

<a>
	<xsl:attribute name="href">
		#<xsl:value-of select="preceding-sibling::div[@class = 'slide' and
position() = 1]/@id"/>
	</xsl:attribute>
	<img src="images/icons/back.gif" border="0"/>
</a>

thanks in advance!

Bjorn Boxstart


 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.