XML : How to add attribute if new letter is introduced?

I have this very simple XML:

  <entries>      <entry>          <name>Allan</name>      </entry>      <entry>          <name>Ben</name>      </entry>      <entry>          <name>Brad</name>      </entry>      <entry>          <name>Charles</name>      </entry>      <entry>          <name>David</name>      </entry>  </entries>    

I also have this XSL that loops over all the entries:

  <?xml version="1.0" encoding="UTF-8"?>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">      <xsl:template match="entries">        <xsl:for-each select="entry">            <span>                <xsl:value-of select="."/>            </span>        </xsl:for-each>    </xsl:template>    </xsl:stylesheet>    

Is there a simple way to add a css class to each entry that starts with a new letter?

In the example above all entries except the one with Brad would get such a class.

Any ideas?

Thanks for your help.

No comments:

Post a Comment