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

Previous/Next element

Subject: Previous/Next element
From: James Cummings <James.Cummings@xxxxxxxxx>
Date: Wed, 9 Jul 2003 23:03:33 +0100 (BST)
xsl 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


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.