Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - merging two sequences in xslt >Thread Next - Re: merging two sequences in xslt Re: merging two sequences in xsltTo: NULL Date: 10/15/2008 5:03:00 PM 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
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="parent">
<xsl:copy>
<xsl:variable name="l1" as="xs:string*" select="tokenize(a, ',')"/>
<xsl:variable name="l2" as="xs:string*" select="tokenize(b, ',')"/>
<ab>
<xsl:value-of select="for $p in 1 to count($l1) return
($l2[$p], $l1[$p])" separator=" "/>
</ab>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
