Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2006, 10:49 PM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to PommyTom Send a message via MSN to PommyTom Send a message via Yahoo to PommyTom
Default Simple Nesting Loop

Hi everyone,

Just hoping someone can point me in the right direction for this (what should be) a fairly simple error...

The problem is that i have a nested loop but the inner loop is failing to read the value-of, am i missing some critical syntax? The inner loop is itself firing, but the individual values aren't shown.

Any help would be greatly appreciated as always,
========================================
START of XML Snippet:
========================================
Code:
<?xml version='1.0' encoding='UTF-8'?>
<DataSection>
<DataItem>

<response_code>00</response_code>
<current_date>9/06/2006</current_date>
<current_year>2006</current_year>
<doors_close>12:53:00 PM</doors_close>
<set_list_id>1 [5.5] [Gus And Franks Magical Tour of Chocolate]</set_list_id>
<set_list_id>Kick Me in The Head [1:30]</set_list_id>
<set_list_id>When you're the best, don't think you're going....</set_list_id>
</DataItem>
</DataSection>
========================================
End of XML Snippet:
========================================

========================================
START of XSL Snippet:
========================================
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/" >

    <h3>Gig Listing</h3>
 
      <xsl:for-each select="DataSection/DataItem">

       <tr>
        <td width="105" valign="top" class="normal"><b>Set List</b></td>
        <td width="425" valign="top" class="normal">
           <xsl:for-each select="set_list_id">
              <xsl:value-of select="set_list_id" /> = Hello
           </xsl:for-each>
        </td>
      </tr>

      </xsl:for-each>
    </table>

  </xsl:template>
</xsl:stylesheet>
========================================
END of XSL Snippet:
========================================


I added the 'HELLO' within the for-each inner loop, so i can clearly see that it prints 3 times. But the actual value-of isn't printing the value...

Any ideas anyone?


Many thanks,

Tom

 
Old June 9th, 2006, 02:04 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

xsl:for-each changes the context node. IN

<xsl:for-each select="set_list_id">
              <xsl:value-of select="set_list_id" /> = Hello
           </xsl:for-each>

the for-each sets the context node to a set_list_id element.

In the value-of, select="set_list_id" means select="child::set_list_id". BUt your set_list_id element does not have a child called set_list_id. Use select=".".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 9th, 2006, 02:16 AM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to PommyTom Send a message via MSN to PommyTom Send a message via Yahoo to PommyTom
Default

Excellent! Thanks Michael, i'll be sure to make a note!

Works perfectly now.


Thanks again,
Tom







Similar Threads
Thread Thread Starter Forum Replies Last Post
Class Nesting Weirdness?? HotBlue Visual Basic 2005 Basics 3 November 8th, 2006 03:22 PM
Nesting queries??? giffordpinchot Access 0 September 20th, 2006 09:58 AM
Select box for loop(probably really simple) interrupt Javascript How-To 2 March 18th, 2005 12:25 PM
simple loop question Adam H-W Classic ASP Basics 2 July 9th, 2004 01:22 AM
Subreports nesting svenvandevelde Crystal Reports 2 February 4th, 2004 12:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.