Subject: Re: string split From: Mike Berrow <mberrow@xxxxxxxxxx> Date: Tue, 19 Sep 2000 08:06:32 -0700 |
For <doc> <elem>5,6,7</elem> </doc> I have the following ======================= <xsl:template match="/"> <xsl:apply-templates select="/doc/elem"/> </xsl:template> <xsl:template match="elem"> <xsl:param name="csv" select="."/> <xsl:variable name="wlist" select="concat(normalize-space(translate($csv,',',' ')),' ')"/> <xsl:variable name="first"> <xsl:if test="$csv!=' '"> <xsl:value-of select="substring-before($wlist, ' ')"/> </xsl:if> </xsl:variable> <a> <xsl:attribute name="href"> <xsl:value-of select="concat('#id',$first)" /> </xsl:attribute> <xsl:value-of select="$first" /> </a> <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> <xsl:variable name="rest" select="substring-after($wlist, ' ')"/> <xsl:if test="$rest"> <xsl:apply-templates select="."> <xsl:with-param name="csv" select="$rest"/> </xsl:apply-templates> </xsl:if> </xsl:template> ======================= Producing <a href="#id5">5</a> <a href="#id6">6</a> <a href="#id7">7</a> There is probably a leaner way. Anyone? -- Mike Berrow -- Lexica XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: string split, Tobias Grundmann | Thread | RE: string split, Pawson, David |
RE: [XSLT/newbie]value-of attribute, Chris Bayes | Date | RE: [XSLT/newbie]value-of attribute, Kay Michael |
Month |