Here is an 8 year old FXSL 1.x (XSLT 1.0 libray, completely written in XSLT 1.0):
test strSplit to Words10.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://exslt.org/common" > <xsl:import href="strSplitWordDel.xsl"/> <xsl:output indent="yes" omit-xml-declaration="yes"/> <xsl:variable name="vLower" select="'abcdefgijklmnopqrstuvwxyz'"/> <xsl:variable name="vUpper" select="'ABCDEFGIJKLMNOPQRSTUVWXYZ'"/> <xsl:template match="/"> <xsl:variable name="vwordNodes"> <xsl:call-template name="str-split-word-del"> <xsl:with-param name="pStr" select="/"/> <xsl:with-param name="pDelimiters" select="', .(	 '"/> </xsl:call-template> </xsl:variable> <xsl:apply-templates select="ext:node-set($vwordNodes)/*"/> </xsl:template> <xsl:template match="word"> <xsl:choose> <xsl:when test="not(position() = last())"> <xsl:value-of select="translate(substring(.,1,1),$vLower,$vUpper)"/> <xsl:value-of select="substring(.,2)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="delim"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet>
When this conversion is applied to the following XML document (test-strSplit-to-Words10.xml):
<t>004.lightning crashes (live).mp3</t>
result :
004.Lightning Crashes (Live).mp3
For this XML document (provided sample):
dInEsh sAchdeV kApil Muk
result :
dInEsh sAchdeV kApil Muk
With a little tweek we get this code :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://exslt.org/common" > <xsl:import href="strSplitWordDel.xsl"/> <xsl:output indent="yes" omit-xml-declaration="yes"/> <xsl:variable name="vLower" select="'abcdefgijklmnopqrstuvwxyz'"/> <xsl:variable name="vUpper" select="'ABCDEFGIJKLMNOPQRSTUVWXYZ'"/> <xsl:template match="/"> <xsl:variable name="vwordNodes"> <xsl:call-template name="str-split-word-del"> <xsl:with-param name="pStr" select="/"/> <xsl:with-param name="pDelimiters" select="', .(	 '"/> </xsl:call-template> </xsl:variable> <xsl:apply-templates select="ext:node-set($vwordNodes)/*"/> </xsl:template> <xsl:template match="word"> <xsl:value-of select="translate(substring(.,1,1),$vLower,$vUpper)"/> <xsl:value-of select="translate(substring(.,2), $vUpper, $vLower)"/> </xsl:template> <xsl:template match="delim"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet>
which now gives the desired result :
dInEsh sAchdeV kApil Muk
Explanation
The str-split-word-del FXSL template can be used to tokenize (possibly more than one) the delimiters specified as a string parameter.
Dimitre novatchev
source share