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

Re: Nesting for-each elements - Can it be done?

Subject: Re: Nesting for-each elements - Can it be done?
From: "Chris Eckert" <ceckert@xxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 15:55:19 -0700
chris eckert
1. First, update the MSXML processor to the XSLT compliant version. See the
FAQ at http://www.netcrucible.com/xslt/msxml-faq.htm.

This isn't why your transformation is failing, but most subscribers to the
list use XSLT (not the MS specific dialect TR-WD)

2. The 2nd for-each is not matching any elements because their is no
web_seminars child element of the current context node. The first for-each
makes the context the web_seminars element. The second for-each is looking
for the web_seminars child of the web_seminars element. None exists, so
nothing is displayed.

3. You really should be using apply-templates instead of for-each. I have
included a sample transformation that uses both, to illustrate the
apply-templates approach.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
   <table border="0" cellspacing="5" cellpadding="0" width="350"
bgcolor="#EEEEEE">
 <xsl:apply-templates />
   </table>
</xsl:template>

<xsl:template match="seminar">
   <tr>
      <td colspan="2" valign="top">
         <i><xsl:value-of select="seminar_topic"/></i><br />
         Presented by <xsl:value-of select="seminar_speaker/speaker_name"/>,
        <xsl:value-of select="seminar_speaker/speaker_title"/>,
        <xsl:value-of select="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="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 select="." /></xsl:attribute>
  </xsl:element>
  <xsl:value-of select="." /><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>
</xsl:template>
</xsl:stylesheet>

Have fun,
Chris Eckert



 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.