[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Returning a string from a function
I have the following in a stylesheet:
<xsl:function name="local:logicalName"> <xsl:param name="name"/> <xsl:analyze-string select="$name" regex="_"> <xsl:non-matching-substring> <xsl:variable name="substring" select="."/> <xsl:choose> <xsl:when test="$locals/lookup/words/word[@physical=$substring]"> <xsl:choose> <xsl:when test="$locals/lookup/words/word[@physical=$substring and @logical='*']"> <xsl:value-of select="$substring"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$locals/lookup/words/word[@physical=$substring]/@logical"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="$locals/lookup/words/word[@shortPhysical=$substring]"> <xsl:choose> <xsl:when test="$locals/lookup/words/word[@shortPhysical=$substring and @logical='*']"> <xsl:value-of select="$substring"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$locals/lookup/words/word[@shortPhysical=$substring]/@logical"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(substring(., 1, 1), lower-case(substring(., 2)))"/> </xsl:otherwise> </xsl:choose> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:function> The $locals document contains reserved words that have special conversion rules, like this: <?xml version="1.0"?> <lookup> <words> <word physical="ACCT" shortPhysical="*" comment="*" logical="Account"/> ... <word physical="ZIP" shortPhysical="*" comment="*" logical="*"/> </words> </lookup> What I would like it to do is convert ACCOUNT_TO_GROUP into AccountToGroup via <xsl:value-of select="local:logicalName(@name)"/> but instead it is putting spaces between the words. I understand that xsl:function is defined to return a sequence which is what I guess is going on here. I can use string-join to squish them back together, but is there a way to output the desired result from the function directly? Thanks, Barry
|
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
|