logo       

RE: XSL Question: msg#00061

Subject: RE: XSL Question
Thanks, but in this where do I need to pass the //child 

<xsl:template name="split">
   <xsl:param name="input-string"/>
   <xsl:param name="separator"/>

   <xsl:if test="$input-string">
     <td><xsl:value-of
        select="substring-before($input-string, $separator)/></td>
     <xsl:call-template name="split">
       <xsl:with-param name="input-string"
         select="substring-after($input-string, $separator"/>
       <xsl:with-parma name="separator" select="$separator"/>
   </xsl:if>
</xsl:template>




-----Original Message-----
From: Raffaele Sena [mailto:raff-wjLoM/DVabRg9hUCZPvPmw@xxxxxxxxxxxxxxxx] 
Sent: Wednesday, May 24, 2006 9:17 AM
To: Rajashekaraiah, Rashmi (HP-IT)
Cc: talk-KUd/JJajPrLQT0dZR+AlfA@xxxxxxxxxxxxxxxx
Subject: Re: [xquery-talk] XSL Question


since you posted this on the xquery forum I am assuming you are talking
about XPath 2.0 functionalities.

With XPath 2.0 you can use the fn:tokenize() function to split your
comma-separated list:

        fn:tokenize(//child, ',')

returns
        ('name1', 'name2_pewe', 'name3')

If you want to be XSLT 1.0 - XPath 1.0 compliant you can write a
recursive function that uses fn:substring-before and fn:substring-after:

<xsl:template name="split">
   <xsl:param name="input-string"/>
   <xsl:param name="separator"/>

   <xsl:if test="$input-string">
     <td><xsl:value-of
        select="substring-before($input-string, $separator)/></td>
     <xsl:call-template name="split">
       <xsl:with-param name="input-string"
         select="substring-after($input-string, $separator"/>
       <xsl:with-parma name="separator" select="$separator"/>
   </xsl:if>
</xsl:template>

(I didn't really try this but it should be "almost" correct :)

-- Raffaele


Rajashekaraiah, Rashmi (HP-IT) wrote:
> Hi :
>  
> I have a XML which looks like :
> <root><child>name1,name2_pewe,name3</child></root>
>  
>  
> I want to write an xsl to trasnform this to html which should look 
> like <html> <body> <table> <tr><td>name1<td><td></td><td></td><tr>
> </table>
> <body>
> </html>
>  
> I dono how to write a split function in xslt. please help
>  
> Thanks,
> Rashmi
>  
> !DSPAM:4473c46a146357962374464!
> 
> 
> ----------------------------------------------------------------------
> --
> 
> _______________________________________________
> talk-KUd/JJajPrLQT0dZR+AlfA@xxxxxxxxxxxxxxxx
> http://xquery.com/mailman/listinfo/talk
> 
> !DSPAM:4473c46a146357962374464!



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe