<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="xml" indent="yes"/>
	<xsl:template name="ProcessString">
		<!--This template will recursively process a string of characters and 
		    place a <br/> before each uppercase character-->

		<xsl:param name="strInput" select="''"/>
		
		<xsl:variable name="strCurrChar" select="substring($strInput, 1, 1)"/>
		<xsl:variable name="strRemainingChars" select="substring($strInput, 2)"/>
		
		
		<xsl:choose>
				<!--the test below will be false when strCurrChar is empty. -->
				<xsl:when test="$strCurrChar">

				<!-- Test to see if the character is upper case.  (in a very cool fashiong), if so, output a <br/> -->	
				<xsl:if test="not(translate($strCurrChar ,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',''))">
					<br/>
				</xsl:if>

				
				<!--	BTW, the test above is known as "Ken's trick" (submitted by Ken G. Holman) for a test of
				    	an upper-case character.   It is WAY cool IMHO, but a bit subtle.  Here's how it works:
					a) Translate() won't touch characters that aren't in the second argument.
					b) If the first argument contains only upper case characters, they are all deleted and nothing 
					else is touched.
					c) If the resulting string is empty (meaning every character was upper-case
					 and was deleted), the empty string tests as FALSE, and the not() changes it to TRUE
					d) So...the entire "test=" is TRUE if the first argument contains only upper-case characters.-->


				<!-- Output the current character -->
				<xsl:value-of select="$strCurrChar"/>


				<!-- At this point, the template will recursively call itself with the remaining
				     characters in the string -->
				<xsl:call-template name="ProcessString">
					<xsl:with-param name="strInput" select="$strRemainingChars"/>
				</xsl:call-template>
			</xsl:when>

		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
