Re: How to Display multiple items

Subject: Re: How to Display multiple items
From: Phil Lanch <phil@xxxxxxxxxxxxxxx>
Date: Thu, 02 Dec 1999 12:23:29 +0000
> <subject>
> <topic>Communication within the team - importance of team meetings</topic>
> <method>Micro-planning</method>
> <method>Creating a structure, defining processes and roles</method>
> <method>Briefing new members</method>
> <method>Sharing news</method>
> </subject>
> 
> As you can see, there are multiple <method> tags.
> I am using XSLT to display the contents.
> i Use follwing code in XSL:-
> 
> <xsl:template match="subject">
> <font class="display"><b><xsl:value-of select="topic" /></b></font><br />
> <font class="display"><xsl:value-of select="method" /></font><br />
> </xsl:template>
> 
> But only first <method> tags values are displayed.

Your select="method" _does_ select a list of all the <method> nodes;
however, when a node-list is converted to a string, only the fist node
is used.

> CAn anyone tell me, how to display values of all <method> tags.

You could try iterating over the <method> elements:

<xsl:template match="subject">
<font class="display"><b><xsl:value-of select="topic" /></b></font><br
/>
<xsl:for-each select="method">
  <font class="display"><xsl:value-of select="." /></font><br />
</xsl:for-each>
</xsl:template>

That's OK, but when your stylesheets get more complicated it's clearer
to split them up into separate templates:

<xsl:template match="subject">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="topic">
  <font class="display"><b><xsl:apply-templates/></b></font><br />
</xsl:template>

<xsl:template match="method">
  <font class="display"><xsl:apply-templates/></font><br />
</xsl:template>

-- 

bah, humbug

phil

*witness relocation program alumnus*


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


Current Thread