[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Returning a string from a function

Subject: Returning a string from a function
From: Barry Lay <blay@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 09 Jun 2004 17:41:43 -0400
function returning string
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.