[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Previous/Next element
Subject: [xsl] Previous/Next element From: James Cummings <James.Cummings@xxxxxxxxx> Date: Wed, 9 Jul 2003 23:03:33 +0100 (BST) |
Ok, I know this is a FAQ.... but I want to have a link to the previous sibling and another to the following sibling. Given: <CURSUS> <text> <body> <Day code="6000"> blah </Day> <Day code="6010"> blort </Day> <Week code="8012"> foo </Week> <Day code="3200"> blah </Day> ... </body> </text> </CURSUS> and ---- <xsl:template match="Day | Week"> <div class="{name()}" id="{concat($ms, '.',@code)}"> <xsl:if test="preceding-sibling::*/@code"> <span class="prev"> <a href="{concat('#', $ms, '.', preceding-sibling::*/@code)}">Prev</a> </span><xsl:text> </xsl:text> </xsl:if> <xsl:if test="following-sibling::*/@code"> <span class="next"> <a href="{concat('#', $ms, '.', following-sibling::*/@code)}">Next</a> </span></xsl:if> </div> <xsl:apply-templates /> </div> </xsl:template> etc. ---- So each Day or Week is turned into a <div> with an @id of blah.6000 based on its @code and a global variable $ms. The 'next' button following-sibling::*/@code seems to work well, not minding whether it is Day or Week. The 'Prev' button always goes back to the first one. I realise the usual way to do this is based on count() or position(), but since I want to base it on the previous/following's Day/Week's @code, I wasn't sure how to do this. Suggestions? -James -- Dr James Cummings, James.Cummings@xxxxxxxxx, http://www.uea.ac.uk/~q503 Cursus Project, School of Music, University of East Anglia, Norwich, Norfolk, NR4 7TJ, UK Tel:(01603)593-595 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] generating unique Id and , Anil | Thread | RE: [xsl] Previous/Next element, Conal Tuohy |
[xsl] Formatting hyperlinks and par, Peter Simard | Date | RE: [xsl] XSLT Problem, Lars Huttar |
Month |