xsl-list
[Top] [All Lists]

Re: [xsl] Tokenize comma separated string in XSL

2007-03-21 04:21:33
Lalit(_dot_)Chanchlani(_at_)iflexsolutions(_dot_)com wrote:
Hi All,
I have a comma-separated string like ABC,DEF,GHI which I want to
tokenize and return to a template which retrieves separately its
corresponding code from a XML input.
What version of XSLT are you using?

In XSLT 2, this is:

<xsl:for-each select="tokenize($your_input, ',')" >
   <Description value="{.}" />
</xsl:for-each>

In XSLT 1, use a recursive template call with substring-before and substring-after to "walk" through the string.

The output should be:
<AllCodes>
   <Code value = "A">
      <Description="ABC">
your output is not valid XML and as such is not (easily) possible with XSLT. I assume you meant something else?

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

--~------------------------------------------------------------------
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>
--~--

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