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

Re: monotonous nbsp coding

Subject: Re: monotonous nbsp coding
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 13 Nov 2002 17:45:33 -0500
xsl nbsp
Both the earlier suggestions are good.

To answer Greg's question about the parameters, a named template takes the calling context as its context, so no parameter is needed here.

To combine the suggestions, consider the following:

<xsl:template name="fillcell">
  <xsl:value-of select="."/>
  <xsl:if test="not(string())">&#160;</xsl:if>
</xsl:template>

<xsl:template match="cell">
  <td>
    <xsl:call-template name="fillcell"/>
  </td>
</xsl:template>

Cheers,
Wendell

At 05:06 PM 11/13/2002, Greg wrote:
At 02:50 PM 11/13/2002, you wrote:
<td>
  <xsl:choose>
    <xsl:when test="string-length() &gt; 0"><xsl:value-of select="."
/></xsl:when>
    <xsl:otherwise>&nbsp;</xsl:otherwise>
  </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!

Make a template that does just that. <xsl:template name="monotonous"> <xsl:param name="str" select="." /> <xsl:value-of select="$str" /> <xsl:if test="string-length() = 0"> <xsl:text>&nbsp;</xsl:text> </xsl:if> </xsl:call-template>

and then you have

<td>
  <xsl:call-template name="monotonous" />
</td>

I don't think you need to explicitly pass the parameter because of the default value, but play with it to make sure. You may need to include the line
<xsl:with-param name="str" select="." />
but I hope not.


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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.