|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Finding the first node in a group in xsl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|