[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Processing a Sequence of String Tokens in XSLT 2
I suspect this is an FAQ, and if so, feel free to point me to existing discussion, but I'm curious as to what the most efficient/elegant way to process a sequence of string tokens is. In my specific case, I need to init-cap all the words in a string (I don't need any sophistication like special case for conjunctions or anything). Here's the XSLT 2 function I came up with: <xsl:function name="func:normalizeTitleContent"> <!-- Normalizes the case of titles based on the FASB-defined rules for title case --> <xsl:param name="titleElem"/> <xsl:variable name="titleTokens" select="tokenize(string($titleElem), ' ')"/> <xsl:variable name="resultString"> <xsl:for-each select="$titleTokens"> <xsl:sequence select="concat(upper-case(substring(., 1,1)), substring(., 2))"/> </xsl:for-each> </xsl:variable> <xsl:sequence select="$resultString"/> </xsl:function> Which seems reasonably compact and understandable but I suspect that I'm not doing things as cleverly or as "correctly" as I could. Is there a better way to have written this function? Thanks, Eliot -- W. Eliot Kimber Professional Services Innodata Isogen 8500 N. Mopac, Suite 402 Austin, TX 78759 (214) 954-5198 ekimber@xxxxxxxxxxxxxxxxxxx www.innodata-isogen.com
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|