xsl-list
[Top] [All Lists]

RE: [xsl] Tokenize comma separated string in XSL

2007-03-21 04:39:38
Hi,

I am using XSLT 1.0 In the XSL I get the comma separated string
ABC,DEF,GHI as a parameter which is set by a Java program. 

The output XML should be:

<AllCodes>
   <Code value = "A">
      <Description="ABC"/>
   </Code>
  <Code value = "D">
      <Description="DEF"/>
   </Code>
  <Code value = "G">
      <Description="GHI"/>
   </Code>
</AllCodes>

Can you please give me an example on the recursive template using
substring-before and substring-after?

Thanks,
Lalit

 

-----Original Message-----
From: Abel Braaksma [mailto:abel(_dot_)online(_at_)xs4all(_dot_)nl] 
Sent: Wednesday, March 21, 2007 4:50 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Tokenize comma separated string in XSL

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



DISCLAIMER:
This message contains privileged and confidential information and is intended 
only for an individual named. If you are not the intended recipient, you should 
not disseminate, distribute, store, print, copy or deliver this message. Please 
notify the sender immediately by e-mail if you have received this e-mail by 
mistake and delete this e-mail from your system. E-mail transmission cannot be 
guaranteed to be secure or error-free as information could be intercepted, 
corrupted, lost, destroyed, arrive late or incomplete or contain viruses. The 
sender, therefore,  does not accept liability for any errors or omissions in 
the contents of this message which arise as a result of e-mail transmission. If 
verification is required, please request a hard-copy version.

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