Posted By

Meander365 on 08/13/09


xslt String uppercase fullstop sentenance

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Ensure String First Letter is Capitalised and Has a Full Stop At It's End

 / Published in: XSLT

Useful for handling badly formatted string. You could also use normalize-space to remove bad spaces if needed.

  1. <!-- first char to uppercase-->
  2. <xsl:value-of select="concat( translate( substring( $my-string, 1, 1 ),$lowerCase, $upperCase ), substring( @type, 2, string-length( $my-string )))" />
  3. <!-- remainder of string -->
  4. <xsl:value-of select="substring($my-string,2,string-length($my-string)-1)" />
  5. <!-- fullstop -->
  6. <xsl:if test="substring($my-string,string-length($my-string)) !='.'">.</xsl:if>

Report this snippet  

You need to login to post a comment.