Subject: Re: [xsl] Re: How to merge two elements and transform them into a table From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Sat, 17 May 2008 13:33:15 +0530 |
You need to use a tokenizing functionality to solve this problem. You can use an EXSLT extension for this. Following is a working solution for this problem: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" exclude-result-prefixes="str" version="1.0"> <xsl:output method="html" /> <xsl:template match="/"> <html> <head> <title/> </head> <body> <table> <xsl:variable name="actors" select="str:tokenize(Items/Item/Actors,'|')" /> <xsl:variable name="actorsrole" select="str:tokenize(Items/Item/Actorsrole,'|')" /> <xsl:for-each select="$actors"> <xsl:variable name="x" select="position()" /> <tr> <td> <xsl:value-of select="." /> </td> <td> <xsl:value-of select="$actorsrole[position() = $x]" /> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> On Sat, May 17, 2008 at 12:39 PM, Erik Vullings <erik.vullings@xxxxxxxxx> wrote: > Hi, > > I am trying to convert movie details (from http://www.movie-xml.com) > into a nice HTML page. That works quite well, except for the actor > name/role part, which is in two separate nodes for all actors and > roles - see the Actors and ActorsRole node below: > <Items> > <Item> > <SeriesName>101 Dalmatians</SeriesName> > <Actors>|Glenn Close|Jeff Daniels|Joely Richardson|Joan > Plowright|Hugh Laurie|Mark Williams|John Shrapnel|</Actors> > <Actorsrole>|Cruella De > Vil|Roger|Anita|Nanny|Jasper|Horace|Skinner|</Actorsrole> > <Tagline>So many dogs. So little time.</Tagline> > </Item> > </Items> > > What I would like to obtain is something like the following (in a HTML > table - please also note that the '|' should be removed): > Glenn Close Cruella De Vil > Jeff Daniels Roger > etc. > > I'm quite new to XSLT, and couldn't find anything useful using Google, > so can it be done using XSLT (preferably v1.0)? Any help would be much > appreciated! > > Cheers > Erik -- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: How to merge two elements, Erik Vullings | Thread | Re: [xsl] Re: How to merge two elem, James A. Robinson |
[xsl] Re: How to merge two elements, Erik Vullings | Date | Re: [xsl] Re: How to merge two elem, James A. Robinson |
Month |