XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 19th, 2004, 10:43 PM
batookee batookee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 30 batookee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 20 sec
Reputation Power: 7
Question problem with xsl template

I'm having a bit of a problem with and xsl template im making for an xml database of my music library. (newb)
heres what my xml file looks like in a nutshell
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl" ?>
<collection>
<artist name="AC/DC">
<album>74 Jailbreak</album>
<album>Back In Black</album>
<album>Blow Up Your Video</album>
</artist>
<artist name="Bachman Turner Overdrive">
<album>Not Fragile</album>
...
</collection>


See very simple. When it comes to the XSL stylesheet however I'm having a big of difficulty because there are sometimes more then one album. Here's what it looks like
Code:
<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html> 
<body>

<xsl:for-each select="collection/artist"> 
<b><xsl:value-of select="@name"/></b>
<xsl:value-of select="album"/>
</xsl:for-each> 
</body>
</html>
</xsl:template>
</xsl:stylesheet>


I know I'm doing it wrong because it only displays the first album for every artist. Can anyone help be fix this?

Reply With Quote
  #2  
Old September 20th, 2004, 08:38 AM
Covenent Covenent is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 17 Covenent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You need to do another for-each loop for each album. The following should work:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="/">

  <html> 
  <body>

  <xsl:for-each select="/collection/artist"> 

   <b><xsl:value-of select="@name"/></b>

   <dl>
    <dt>Albums:</dt>
    <xsl:for-each select="./album">
     <dd><xsl:value-of select="." /></dd>
    </xsl:for-each> 
   </dl>

  </xsl:for-each> 

  </body>
  </html>

 </xsl:template>

</xsl:stylesheet>

Reply With Quote
  #3  
Old September 20th, 2004, 04:05 PM
batookee batookee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 30 batookee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 20 sec
Reputation Power: 7
Thanks, I acctualy figured it out last night but thanks anyway

Reply With Quote
  #4  
Old September 20th, 2004, 04:41 PM
Covenent Covenent is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 17 Covenent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by batookee
Thanks, I acctualy figured it out last night but thanks anyway


Thats always the way.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > problem with xsl template


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT