Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Split csv list into multiple elements >Thread Next - Re: Split csv list into multiple elements Re: Split csv list into multiple elementsTo: NULL Date: 3/2/2005 9:37:00 PM Tempore 20:42:09, die Wednesday 02 March 2005 AD, hinc in foro {microsoft.public.xsl} scripsit Luca <luca.milan@g...>:
> <ROOT>
> <Attribute Description="Desc 1" Labels="Label 1,Label 2,Label 3"
> Values="1,2,3"></Attribute>
> </ROOT>
>
> I want this output HTML:
>
> <h1>Desc 1</h1>
> <br/>
> <a href="default.html?Id=1">Label 1</a>,
> <a href="default.html?Id=2">Label 2</a>,
> <a href="default.html?Id=3">Label 3</a>
>
> is possible with Xsl or not?
It is possible, but not very easy in XSLT1.0 to make a flexible function of it...
Here's one attempt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="Attribute">
<h1>Desc 1</h1>
<br/>
<xsl:call-template name="csl2list"/>
</xsl:template>
<xsl:template match="Attribute" mode="list">
<xsl:param name="label" select="@Labels"/>
<xsl:param name="value" select="@Values"/>
<a href="default.html?Id={$label}">
<xsl:value-of select="$value"/>
</a>
</xsl:template>
<xsl:template name="csl2list">
<xsl:param name="label" select="@Labels"/>
<xsl:param name="value" select="@Values"/>
<xsl:apply-templates select="." mode="list">
<xsl:with-param name="label" select="substring-before(concat($value,','),',')"/>
<xsl:with-param name="value" select="substring-before(concat($label,','),',')"/>
</xsl:apply-templates>
<xsl:if test="substring-after($label,',')">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:if test="contains($label,',')">
<xsl:call-template name="csl2links">
<xsl:with-param name="label" select="substring-after($label,',')"/>
<xsl:with-param name="value" select="substring-after($value,',')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Spread the wiki (http://www.wikipedia.org)
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
