xsl-list
[Top] [All Lists]

Re: monotonous nbsp coding

2002-11-27 09:04:42
    <xsl:otherwise>&nbsp;</xsl:otherwise>
you cant do this in XSL.. XSL doesnt define that entity reference..
you may want to use <xsl:text>&#x20</xsl:text> to output space.
    <xsl:when test="string-length(.) &gt; 0">
a better approach would be
    <xsl:when test="string(.)">

BTW, coming to your point,
If you do not want to check on the value of the element, and just output the
text,
Then <xsl:value-of select = "string(.)"/> would do your job.
It doesnt output anything if it is an empty element.
However, If you want to test the element value and output  text
conditionally, then you must use the <xsl:choose>
as you did.

HTH

----- Original Message -----
From: "Zakon, Stuart" <stuart_zakon(_at_)medcohealth(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, November 13, 2002 9:50 PM
Subject: [xsl] monotonous nbsp coding


Some older browsers have a problem rendering tables with empty <td> tags
in
them. (You know which ones...)
Is there a better way to code this in XSLT than the following:

<td>
  <xsl:choose>
    <xsl:when test="string-length() &gt; 0"><xsl:value-of select="."
/></xsl:when>

  </xsl:choose>
</td>

This gets monotonous after a while.  It would be nice if <xsl:value-of>
could take an attribute which would provide a default value if the select
produces an empty result!

Stuart Zakon



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>