xsl-list
[Top] [All Lists]

Re: looping on a line

2005-11-29 04:10:25
On 11/29/05, ADAM PATRICK <adampatrick(_at_)btinternet(_dot_)com> wrote:
could you give an example of a a recursive function
looping on substring-before()?

From our data-source, untested ;

<xsl:template match"/">
   <xsl:for-each select="data">
      <xsl:call-template name="no-ify">
         <xsl:with-param name="data" select="." />
      </xsl:call-template>
   </xsl:for-each>
</xsl:template>

<xsl:template name="no-ify">
   <xsl:param name="data" />
   <xsl:variable name="after" select="substring-after($data,',')" />
   <xsl:choose>
      <xsl:when test="string($after)">
         <no><xsl:value-of select="substring-before($data,',')" /></no>
         <xsl:call-template name="no-ify">
            <xsl:with-param name="data" select="$after" />
         </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
         <no><xsl:value-of select="$data" /></no>
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>

Should roughly do something that you want.


Alex
--
"Ultimately, all things are known because you want to believe you know."
                                                         - Frank Herbert
__ http://shelter.nu/ __________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--