Re: [xsl] Need 'new line' in list

Subject: Re: [xsl] Need 'new line' in list
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Thu, 27 Sep 2001 09:38:40 +0200
Linda Zammit <binky_35@xxxxxxxx> wrote:
> I am trying to insert a new line in a list in order to
> obtain this html display:
[snip]

As Mike already wrote, Browsers ignore ordinary line feeds in
most parts of HTML documents by design, and using <BR> elements
may be a quick fix (purists generally discourage using <BR>).
Try:
 <xsl:variable name="list">
   <xsl:call-template name="make-list">
     <xsl:with-param name="names" select="stuff"/>
   </xsl:call-template>
 </xsl:variable>
 <xsl:copy-of select="$list"/>
 [...]

 <xsl:template name="make-list">
   <xsl:param name="names"/>
   <xsl:for-each select="$names">
     <xsl:value-of select="."/>
     <xsl:if test="position()!=last()">
       <br/>
     </xsl:if>
     <xsl:if test="position()=last()-1"> and </xsl:if>
   </xsl:for-each>
 </xsl:template>

Note that you'll have to use xsl:copy-of instead
of xsl:value-of in order to use the result properly
(try both to get a feeling why this matters).

Untested. HTH anyway.

J.Pietschmann

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


Current Thread