Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


starts-with XSL function - HELP!!

From: allenleila@-------.--- (-----)
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


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent