XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 18th, 2003, 02:30 AM
pramenjatchek pramenjatchek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 pramenjatchek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Finding the first node in a group in xsl

Hi,

I have a file with glossary items that I need to split alphabetically. This is working by just sorting the list, but now I need to add a header above each group of letters, eg the whole group of A entries has a header called 'A entries' above it etc.

Here is the xsl code (just for letter b):

<xsl:template match="finalGlossary">
<xsl:for-each select="hotWord">
<xsl:sort select="hotWordTitle"/>
<p>
<xsl:call-template name="alphaB"/>
<xsl:apply-templates select="hotWordTitle"/>
<xsl:apply-templates select="hotWordTxt"/>
</p>
<p>[<a href="#top">Top</a>]</p>
</xsl:for-each>
</xsl:template>

<xsl:template name="alphaB">
<xsl:if test="hotWordTitle[starts-with(text(),'B')]">
<span class="b">B Entries</span><br/><br/>
</xsl:if>
</xsl:template>

<xsl:template match="hotWordTitle">
<span class="b"><xsl:apply-templates/></span><br/>
</xsl:template>

<xsl:template match="hotWordTxt">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="hotWordBold">
<span class="b"><xsl:apply-templates/></span>
</xsl:template>

The problem is that it puts 'B entries' above each of the items starting with b! The only way that I seem to be able to select the first entry is by checking the position() and then adding an if statement in the alphaB template.

As hardcoding doesn't seem a logical thing to do, is there any way to check which the first entry of a particular letter is, so that only the first item in the group has the header above it?

Thank you

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Finding the first node in a group in xsl


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway