![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: starts-with XSL function - HELP!! starts-with XSL function - HELP!!To: NULL Date: 7/5/2004 3:50:00 AM I have an XML file which looks like this: <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <country>UK</country> <company>CBS Records</company> <price>9.90</price> <year>1988</year> </cd> . . . </catalog> My xslt looks like this: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table border="1" cellpadding="0" cellspacing="0" width="50%"> <tr> <td class="heading" colspan="2">Leila's music box</td> </tr><tr bgcolor="#9acd32"> <td class="textSmall">Artist</td> <td class="textSmall">Title</td> </tr> <xsl:for-each select="catalog/cd"> <xsl:sort select="artist"/> <tr> <xsl:if test = "catalog/cd[starts-with(artist, 'a')]"> <td bgcolor="#B0F3A1"> <xsl:value-of select="artist"/> </td> <td bgcolor="#B0F3A1"> <xsl:value-of select="title"/> </td> </xsl:if> <xsl:if test = "catalog/cd[starts-with(artist, 'b')]"> <td bgcolor="#F3A1A5"> <xsl:value-of select="artist"/> </td> <td bgcolor="#F3A1A5"> <xsl:value-of select="title"/> </td> </xsl:if> . . . </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> I am attempting to use the <xsl:if ...> statement to check which letter the artist name begins with, and depending on that, I change the background colour of the <td> tag. But this line <xsl:if test = "catalog/cd[starts-with(artist, 'b')]"> is not working. What am I doing wrong??? Any help would me most appreciated! Leila | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
