[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Previous/Next element
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|