Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - help with XSLT >Thread Next - Re: help with XSLT Re: help with XSLTTo: NULL Date: 8/1/2006 9:30:00 AM himgi wrote: > In my source XML I have a tag value that is a list of codes. I give u > an example: > <mytag>1,2,33,44,55,6,7,88,99,...,nn</mytag> This is an awkward problem in XSLT (not hard, just awkward). Your input document is more of a text document than an XML document, because the "interesting" part of the parsing is about parsing a text string, not XML. Here's a crude recursive solution. <xsl:template name="foo" > <xsl:param name="list" select="/.." /> <xsl:variable name="car" select="substring-before($list,',')" /> <xsl:variable name="cdr" select="substring-after($list,',')" /> <xsl:choose><xsl:when test="$car" > <MyNewTag><xsl:value-of select="($car)" /></MyNewTag> <xsl:call-template name="foo" > <xsl:with-param name="list" select="($cdr)" /> </xsl:call-template> </xsl:when> <xsl:when test="$list" ><MyNewTag><xsl:value-of select="$list" /></MyNewTag></xsl:when> </xsl:choose> </xsl:template> <xsl:template match="mytag" > <MyNewTags> <xsl:call-template name="foo" > <xsl:with-param name="list" select="text()" /> </xsl:call-template> </MyNewTags> </xsl:template> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
