How to fetch particular element from string after splitting it, using XSLT split() ?
        Posted  
        
            by Vijay
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Vijay
        
        
        
        Published on 2010-06-10T05:48:49Z
        Indexed on 
            2010/06/10
            5:52 UTC
        
        
        Read the original article
        Hit count: 283
        
Hi All,
I have one query regarding XSLT functions. I am using split function to fetch values from a string. I am using separator as "*".
e.g.
String : {"item1*item2*item3*item4"} 
split function I am using is as;
<xsl:template name="SplitItemsCollection">
    <xsl:param name="list" select="''"/>
    <xsl:param name="separator" select="'*'"/>
    <xsl:if test="not($list = '' or $separator = '')">
      <xsl:variable name="head" select="substring-before(concat($list, $separator), $separator)"/>
      <xsl:variable name="tail" select="substring-after($list, $separator)"/>
        <xsl:value-of select="$head"/>
      <xsl:call-template name="split">
        <xsl:with-param name="list" select="$tail"/>
        <xsl:with-param name="separator" select="$separator"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
This function returns me all the items.
 Is there any way to fetch particular item from these separated items ?
 Say I want to fetch item3. Can we do it directly ?
Thanks in advance.
© Stack Overflow or respective owner