[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|