Re: [xsl] Whitespace seperated values into HTML table

Subject: Re: [xsl] Whitespace seperated values into HTML table
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Fri, 31 May 2002 01:33:50 +0200
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">
      <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:template name="tokenize">
<xsl:param name="string"/>
<xsl:param name="delimiter"/>
<xsl:when test="contains($string, $delimiter)">
<xsl:value-of select="substring-before($string, $delimiter)"/>
<xsl:call-template name="tokenize">
<xsl:with-param name="string" select="substring-after($string, $delimiter)"/>
<xsl:with-param name="delimiter" select="' '"/>
<xsl:value-of select="$string"/>

This time I tested the stylesheet and with MSXML I get the expected output.



XSL-List info and archive:

Current Thread