xsl-list
[Top] [All Lists]

[xsl] First steps with high order functions

2018-06-19 05:33:19
Hello,

I'm trying to learn high order functions, and I have some difficulties. If someone could help...


I have a normal function :

  <xsl:function name="nu:camelCase" as="xs:string?">
    <xsl:param name="s" as="xs:string?"/>
    ...
  </xsl:function>


I want to apply it on each word of a sentence :

  <xsl:function name="nu:clearUsername" as="xs:string?">
    <xsl:param name="name" as="xs:string?"/>
    <xsl:choose>
      <xsl:when test="empty($name)"><xsl:sequence select="()"/></xsl:when>
      <xsl:when test="contains($name, ' ')">
        <xsl:variable name="temp" select="tokenize($name, ' ')"/>
        <xsl:sequence select="string-join(for-each($temp, nu:camelCase#1), ' ')"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:sequence select="$name"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:function>

Does the for-each is correct ? Is there another syntax to make this work with Saxon-HE ?

Is there a better way to do this ?

Thanks in advance,
Christophe
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>