This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Whitespace seperated values into HTML table
- From: "Rajput, Ashish S" <ashish dot s dot rajput at lmco dot com>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 31 May 2002 08:33:03 -0500
- Subject: RE: [xsl] Whitespace seperated values into HTML table
- Reply-to: xsl-list at lists dot mulberrytech dot com
Thank you once again Joerg! It works like a charm this time around.
Ashish
-----Original Message-----
From: Joerg Heinicke [mailto:joerg.heinicke@gmx.de]
Sent: Thursday, May 30, 2002 6:34 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] Whitespace seperated values into HTML table
Rajput, Ashish S wrote:
> Hello Joerg, thank you for your response.
>
> I'm a newbie to XSL, and I've been unable to get this to work yet
with the
> suggested recursive template using the MSXML4 parser. Once again, I'm
> trying to normalize whitespace between Strings, and to also display each
> individual string in it's own column. Is there some sort of a tutorial
> available for Dimitre's FXSL? All other suggestions are most welcome.
> Kindly include some code as well. Thank you!
>
> Part of XML File:
> <parameter name="Sensors">
> <valueList size="4">sensorAAA sensorBBB sensorCCC sensorDDD</valueList>
> </parameter>
>
>
> Target Output:
> ___________________________________________________________
> |Sensors |sensorAAA|sensorBBB|sensorCCC|sensorDDD|
> -----------------------------------------------------------
>
> Ashish Rajput
Sorry, but there was a little bug in the stylesheet. Twice I wrote
<xsl:with-param name="delimiter" select=" "/>,
where the space in select-attribute will be used as XPATH-expression,
but it isn't a valid one. It has to be string, so it must be
<xsl:with-param name="delimiter" select="' '"/>.
After some little other not so important changes the stylesheet looks like:
<xsl:template match="parameter">
<table border="1">
<tr>
<td><xsl:value-of select="@name"/></td>
<xsl:call-template name="tokenize">
<xsl:with-param name="string" select="valueList"/>
<xsl:with-param name="delimiter" select="' '"/>
</xsl:call-template>
</tr>
</table>
</xsl:template>
<xsl:template name="tokenize">
<xsl:param name="string"/>
<xsl:param name="delimiter"/>
<xsl:choose>
<xsl:when test="contains($string, $delimiter)">
<td>
<xsl:value-of select="substring-before($string, $delimiter)"/>
</td>
<xsl:call-template name="tokenize">
<xsl:with-param name="string" select="substring-after($string,
$delimiter)"/>
<xsl:with-param name="delimiter" select="' '"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="$string"/>
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
This time I tested the stylesheet and with MSXML I get the expected output.
Regards,
Joerg
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list