[xsl] Nesting for-each elements - Can it be done?

Subject: [xsl] Nesting for-each elements - Can it be done?
From: Chuck Evans <chuck.evans@xxxxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 12:58:56 -0700
I'm new to the list and have checked the FAQ and didn't see this addressed.
My problem might be with my XSL or it might be that I'm conceiving of the
wrong structure for my XML in the first place. Any and all help will be
appreciated.

I want to be able to nest a for-each element within another one so that,
when the first one executes, it displays information with a small part in
the middle that loops through a subsection of the XML file to display
several dates.

The way I have it now (code below), I get the first part of the information
for the first seminar, but nothing under the dates. If I move the first
for-each to only wrap around the table row with the topic/speaker, etc. info
in it (separating the two for-each elements) then I get the first seminar
information with all six dates where just three should be (but with the
radio buttons as wanted).

What I want for output is:

The First in a Series of Seminars
Presented by John Smith, Vice President of Product Marketing, Smithco, Inc.

Available Dates (Select One): [] August 21, 2001
                              [] August 23, 2001
                              [] August 28, 2001

Note: All Web Seminars begin at 11:00AM US Pacific Time (2:00PM US Eastern
Time).


The Second in a Series of Seminars
Presented by George Jones, Web Marketing Manager, Jonesco, LLP

Available Dates (Select One): [] September 14, 2001
                              [] September 16, 2001
                              [] September 19, 2001

Note: All Web Seminars begin at 11:00AM US Pacific Time (2:00PM US Eastern
Time). 


Here's the XML:

<web_seminars>

<seminar>
<seminar_topic>The First in a Series of Seminars</seminar_topic>
<seminar_speaker>
   <speaker_name>John Smith</speaker_name>
   <speaker_title>Vice President of Product Marketing</speaker_title>
   <speaker_affiliation>Smithco, Inc.</speaker_affiliation>
</seminar_speaker>
<seminar_dates>
   <individual_date>August 21, 2001</individual_date>
   <individual_date>August 23, 2001</individual_date>
   <individual_date>August 28, 2001</individual_date>
</seminar_dates>
</seminar>

<seminar>
<seminar_topic>The Second in a Series of Seminars</seminar_topic>
<seminar_speaker>
   <speaker_name>George Jones</speaker_name>
   <speaker_title>Web Marketing Manager</speaker_title>
   <speaker_affiliation>Jonesco, LLP</speaker_affiliation>
</seminar_speaker>
<seminar_dates>
   <individual_date>September 14, 2001</individual_date>
   <individual_date>September 16, 2001</individual_date>
   <individual_date>September 19, 2001</individual_date>
</seminar_dates>
</seminar>

</web_seminars>

And here's the XSL:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>
<xsl:template match="/">

<xsl:for-each select="web_seminars">

<table border="0" cellspacing="5" cellpadding="0" width="350"
bgcolor="#EEEEEE">

<tr>
<td colspan="2" valign="top">
<i><xsl:value-of select="seminar/seminar_topic"/></i>
<br />Presented by <xsl:value-of
select="seminar/seminar_speaker/speaker_name"/>, <xsl:value-of
select="seminar/seminar_speaker/speaker_title"/>, <xsl:value-of
select="seminar/seminar_speaker/speaker_affiliation"/><hr size="1"
width="100%" />
</td>
</tr>

<tr>
<td valign="top">
Available Dates (Select One):
</td>
<td valign="top">

<xsl:for-each select="web_seminars/seminar/seminar_dates/individual_date">

<xsl:element name="input">
<xsl:attribute name="type">radio</xsl:attribute>
<xsl:attribute name="name">seminar_date</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of /></xsl:attribute>
</xsl:element>
<xsl:value-of /><br />

</xsl:for-each>

</td>
</tr>

<tr>
<td colspan="2" valign="top">
<hr size="1" width="100%" />
<i>Note:</i> All Web Seminars begin at 11:00AM US Pacific Time (2:00PM US
Eastern Time).
</td>
</tr>

</table>

<br />

</xsl:for-each>

</xsl:template>
</xsl:stylesheet>



Thank you in advance for any help.

Chuck Evans
Webmaster
Click2learn, Inc.

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


Current Thread