Removing white space inside quotes in XSLT

Posted by fudgey on Stack Overflow See other posts from Stack Overflow or by fudgey
Published on 2010-03-13T00:10:39Z Indexed on 2010/03/13 0:17 UTC
Read the original article Hit count: 636

Filed under:
|

I'm trying to format a table from XML. Lets say I have this line in the XML

<country>Dominican Republic</country>

I would like to get my table to look like this

<td class="country DominicanRepublic">Dominican Republic</td>

I've tried this:

<td class="country {country}"><xsl:value-of select="country"/></td>

then this:

<xsl:element name="td">
 <xsl:attribute name="class">
  <xsl:text>country </xsl:text>
  <xsl:value-of select="normalize-space(country)"/>
 </xsl:attribute>
<xsl:value-of select="country"/>
</xsl:element>

The normalize-space() doesn't remove the space between the two parts of the name and I can't use <xsl:strip-space elements="country"/> because I need the space when I display the name inside the table cell.

How can I strip the space from the value inside the class, but not the text in the cell?

© Stack Overflow or respective owner

Related posts about xsl

Related posts about whitespace