[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Whitespace seperated values into HTML table

Subject: Re: Whitespace seperated values into HTML table
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Fri, 31 May 2002 01:33:50 +0200
Re:  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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.