﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="xml" indent="yes"/>
	<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
	<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />

	<xsl:template name="GetFirstLastWord">
		<xsl:param name="value"  select="'N/A'"/>
		<xsl:param name="Style" select="'N/A'"/>
		<xsl:variable name="length" select="string-length($value)"/>
		<span style="{$Style}">
			<span title="{$value}" class="nme">
				<xsl:choose>
					<xsl:when test="$length &gt; 2">
						<xsl:choose>
							<xsl:when test="substring-after($value,' ')">
								<xsl:variable name="LastName" select="substring-after($value,' ')"></xsl:variable>
								<xsl:variable name="LastNameLength" select="string-length($LastName)"></xsl:variable>
								<xsl:value-of select="translate(substring($value,1,1), $smallcase, $uppercase)"/>
								<xsl:value-of select="translate(substring($LastName,1,1), $smallcase, $uppercase)"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="translate(substring($value,1,1), $smallcase, $uppercase)"/>
								<xsl:value-of select="translate(substring($value,($length),($length)), $smallcase, $uppercase)"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="translate($value, $smallcase, $uppercase)" />
					</xsl:otherwise>
				</xsl:choose>
			</span>
		</span>
	</xsl:template>
</xsl:stylesheet>
