Subject: Re: [xsl] Returning a string from a function From: Barry Lay <blay@xxxxxxxxxxxxxxxxxxx> Date: Wed, 09 Jun 2004 19:00:47 -0400 |
I'll do that part.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!
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Returning a string from a, Michael Kay | Thread | eacutes driving me nuts, Deirdre Saoirse Moen |
RE: [xsl] Returning a string from a, Michael Kay | Date | eacutes driving me nuts, Deirdre Saoirse Moen |
Month |