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

Re: Returning a string from a function

Subject: Re: Returning a string from a function
From: Barry Lay <blay@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 09 Jun 2004 19:00:47 -0400
returning a string
Thank you very much sir. I am still learning XSLT 2.0 and this gives me a chance to examine the enhancements to the expression syntax.

Michael Kay wrote:

If the select expression in xsl:value-of is returning a sequence of strings,
and you want the strings joined together without a separator, you can
specify separator="" on the xsl:value-of instruction (the default value is
separator=" ", a single space).

However, If you want to return a string from the function, rather than a
text node, I would suggest using xsl:sequence rather than xsl:value-of. You
will then need to use string-join() to merge the strings in the sequence.

To show you an alternative coding style, I would be inclined to write this
function as:

<xsl:function name="local:logicalName" as="xs:string">
<xsl:param name="name" as="xs:string"/>
<xsl:variable name="words" as="element()*"
select="$locals/lookup/words/word"/>
<xsl:variable name="mapped-words" as="xs:string*" select="
for $substring in tokenize($name, '_') return
if ($words[@physical=$substring])
then if ($words[@physical=$substring and @logical eq '*'])
then $substring
else $words[@physical=$substring]/@logical
else if ($words[@shortPhysical=$substring])
then if ($words[@shortPhysical=$substring and @logical='*'])
then $substring
else $words[@shortPhysical=$substring]/@logical
else concat(substring(., 1, 1), lower-case(substring(., 2)))
"/>
<xsl:sequence select="string-join($mapped-words, '')"/>
</xsl:function>


Not tested!



I'll do that part.

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.