Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 20th, 2005, 08:29 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to deepsweech
Default XLST Multiple Foreach

Hi. need your help here.
i have this sample xml
<ROOT>
  <Rapers>
  <Name>Puff Diddy</Name>
  <Category>
    <CatID>001</CatID>
    <CatID>002</CatID>
    <CatID>003</CatID>
    <CatID>004</CatID>
  </Category>
  <Songs>
    <SongID>Rap1</SongID>
    <SongID>Rap2</SongID>
  </Songs>
  <Name>2Pac</Name>
  <Category>
    <CatID>001</CatID>
    <CatID>002</CatID>
  </Category>
  <Songs>
    <SongID>Rap1</SongID>
    <SongID>Rap2</SongID>
    <SongID>Rap3</SongID>
  </Songs>
  </Rapers>
</ROOT>

now here is my objective, I want to loop through node Raps and display it according to category, and also display all SongID of each node Rapers
I already did a foreach in Rapers and an foreach/if condition for Category but i can't display the list of songs using the foreach for Songs

Please give me an idea of how to do this, thanks!
Jay
Reply With Quote
  #2 (permalink)  
Old June 20th, 2005, 08:33 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Show us your code, and someone will be able to tell you where you went wrong.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old June 20th, 2005, 09:04 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to deepsweech
Default

Hi! thanks for the quick reply, apreciate it!
i have my codes in the office, actually i'm working on Weblogics XTAGS which is somehow very similar to XSL, but to give you an idea, my code is somewhat like this:
<xtags:parse>
<xtags:foreach select="Rapers">
   <xtags:foreach select="Category/CategoryList">
   <xtags:variable id="CATID" select="CatID"/>
     <xtags:if test="$CATID='001'">
        <xtags:valueOf select="Name"/>
        <xtags:foreach select="Songs/SongList">
           <xtags:valueOf select="SongID"/>
        </xtags:foreach>
     </xtags:if>
   </xtags:foreach>
</xtags:foreach>
</xtags:parse>

And my XML is like this

<ROOT>
  <Rapers>
  <Name>Puff Diddy</Name>
  <Category>
    <CategoryList>
     <CatID>001</CatID>
     <CatName>English</CatID>
    </CategoryList>
    <CategoryList>
     <CatID>002</CatID>
     <CatName>Chinese</CatName>
    </CategoryList>
  </Category>
  <Songs>
    <SongList>
      <SongID>Rap1</SongID>
      <SongName>Dirty YO!</SongName>
    </SongList>
    <SongList>
      <SongID>Rap2</SongID>
      <SongName>YEEP TEEP</SongName>
    </SongList>
  </Songs>
  </Rapers>

  <Rapers>
  .....
  </Rapers>
</ROOT>

my code displays the rapers and filter them according to category but the songs dont display.

This is what i can remember... sorry i'm still new to xsl
thanks again!
Reply With Quote
  #4 (permalink)  
Old June 20th, 2005, 09:46 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You're not using XSLT, you're using a proprietary language, so you should go to the vendor of that language for support.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
foreach with two lists silasla C# 13 May 2nd, 2008 12:27 PM
how to use pagination in xsl or xlst vijayanmsc XSLT 1 June 6th, 2006 06:07 AM
XLST transformNode problem beyondtron Classic ASP XML 0 February 4th, 2004 04:52 PM
for loops from within foreach richard.york Pro PHP 5 October 2nd, 2003 01:54 AM
XLST vs Sever Controls skin XSLT 3 July 11th, 2003 01:29 PM



All times are GMT -4. The time now is 05:05 AM.


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