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 20th, 2005, 08:29 AM
Registered User
 
Join Date: Jun 2005
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
 
Old June 20th, 2005, 08:33 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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
 
Old June 20th, 2005, 09:04 AM
Registered User
 
Join Date: Jun 2005
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!
 
Old June 20th, 2005, 09:46 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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





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





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