Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: merging two sequences in xslt >Thread Next - Re: merging two sequences in xslt Re: merging two sequences in xsltTo: NULL Date: 10/15/2008 9:09:00 AM Martin! thanks alot! cheers, Johannes On 15 Okt., 17:02, Martin Honnen <mahotr...@yahoo.de> wrote: > JMan wrote: > > Hi, > > i have some xml that looks like this: > > > <parent> > > <a>1,2,3,4,5,6,7,8</a> > > <b>a,b,c,d,e,f,g,h</b> > > </parent> > > > what i need i this: > > <parent> > > <ab>a 1 b 2 c 3 d 4 ...</ab> > > </parent> > > > How can i do this? I thought of tokenizing the values of <a> and <b> > > into sequences, but i dont know how to merge them together. > > <xsl:stylesheet > =A0 =A0xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" > =A0 =A0xmlns:xs=3D"http://www.w3.org/2001/XMLSchema" > =A0 =A0exclude-result-prefixes=3D"xs" > =A0 =A0version=3D"2.0"> > > =A0 =A0<xsl:template match=3D"parent"> > =A0 =A0 =A0<xsl:copy> > =A0 =A0 =A0 =A0<xsl:variable name=3D"l1" as=3D"xs:string*" select=3D"toke= nize(a, ',')"/> > =A0 =A0 =A0 =A0<xsl:variable name=3D"l2" as=3D"xs:string*" select=3D"toke= nize(b, ',')"/> > =A0 =A0 =A0 =A0<ab> > =A0 =A0 =A0 =A0 =A0<xsl:value-of select=3D"for $p in 1 to count($l1) retu= rn > ($l2[$p], $l1[$p])" separator=3D" "/> > =A0 =A0 =A0 =A0</ab> > =A0 =A0 =A0</xsl:copy> > =A0 =A0</xsl:template> > > </xsl:stylesheet> > > -- > > =A0 =A0 =A0 =A0 Martin Honnen > =A0 =A0 =A0 =A0http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
