Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 09-24-09   #1 (permalink)
New to Overclock.net
 
IaN-'s Avatar
 
intel nvidia

Join Date: Sep 2007
Location: San Diego, CA
Posts: 35

Rep: 3 IaN- Unknown
Unique Rep: 2
Trader Rating: 0
Default XML & XSL Help

I cannot seem to get each album and each of the 5 songs of all of the albums to display beneath the respective bands/albums. I've tried many different things and have spent quite a few hours working on this. For some reason only the first song will display for each album. Any help would be appreciated.

XML File
Code:
<?xml version ="1.0"?>
<?xml-stylesheet type ="text/xsl" href="Favorite_Music_2.xsl"?>
<?xml-stylesheet type ="application/xml" href="Favorite_Music_2.xsl"?>

<FAVORITEMUSIC>

  <BAND BAND_NAME="Motley Crue">
    <ALBUM ALBUM_NAME="Greatest Hits Package">
      <SONG SONG_NAME="Live Wire"/>
      <SONG SONG_NAME="Public Enemy #1"/>
      <SONG SONG_NAME="Take Me To The Top"/>
      <SONG SONG_NAME="Merry-Go-Round"/>
      <SONG SONG_NAME="Piece Of Your Action"/>
    <ALBUM PRICE="$19.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="Daughtry">
    <ALBUM ALBUM_NAME="Leave This Town">
      <SONG SONG_NAME="You Don&apos;t Belong"/>
      <SONG SONG_NAME="No Surprise"/>
      <SONG SONG_NAME="Everytime You Turn Around"/>
      <SONG SONG_NAME="Life After You"/>
      <SONG SONG_NAME="What I Meant to Say"/>
    <ALBUM PRICE="$15.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>
  

  <BAND BAND_NAME="3Oh!3">
    <ALBUM ALBUM_NAME="WANT">
      <SONG SONG_NAME="Tapp"/>
      <SONG SONG_NAME="Punk*****"/>
      <SONG SONG_NAME="Don&apos;t Trust Me"/>
      <SONG SONG_NAME="Chokechain"/>
      <SONG SONG_NAME="I&apos;m Not Your Boyfriend Baby"/>
    <ALBUM PRICE="$9.99 USD"/>
    </ALBUM>
    <ALBUM ART=""/>
  </BAND>

  <BAND BAND_NAME="Metallica">
    <ALBUM ALBUM_NAME="Garage Inc."> 
      <SONG SONG_NAME="Free speech for the Dumb"/>
      <SONG SONG_NAME="It&apos;s Electric"/>
      <SONG SONG_NAME="Sabbra Cadabra"/>
      <SONG SONG_NAME="Turn the Page"/>
      <SONG SONG_NAME="Die, Die My Darling"/>
    <ALBUM PRICE="$19.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>
  
  <BAND BAND_NAME="Ozzy Osbourne">
    <ALBUM ALBUM_NAME="Essential Ozzy Osbourne">
      <SONG SONG_NAME="Crazy Train"/>
      <SONG SONG_NAME="Mr. Crowley"/>
      <SONG SONG_NAME="I Don&apos;t Know"/>
      <SONG SONG_NAME="Suicide Solution"/>
      <SONG SONG_NAME="Goodbye to Romance"/>
    <ALBUM PRICE="$59.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="Alanis Morissette">
    <ALBUM ALBUM_NAME="Jagged Little Pill">
      <SONG SONG_NAME="All I Really Want"/>
      <SONG SONG_NAME="You Ought Know"/>
      <SONG SONG_NAME="Perfect"/>
      <SONG SONG_NAME="Hand In My Pocket"/>
      <SONG SONG_NAME="Right Through You"/>
    <ALBUM PRICE="$29.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="My Chemical Romance">
    <ALBUM ALBUM_NAME="Three Cheers for Sweet Revenge">
      <SONG SONG_NAME="Helena"/>
      <SONG SONG_NAME="Give&apos;em Hell Kid"/>
      <SONG SONG_NAME="To the End"/>
      <SONG SONG_NAME="You Know What They Do To Guys Like Us In Prison"/>
      <SONG SONG_NAME="I&apos;m Not Okay (I Promise)"/>
    <ALBUM PRICE="$14.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>


  <BAND BAND_NAME="Incubus">
    <ALBUM ALBUM_NAME="Make Yourself">
      <SONG SONG_NAME="Privilege"/>
      <SONG SONG_NAME="Nowhere Fast"/>
      <SONG SONG_NAME="Consequence"/>
      <SONG SONG_NAME="The Warmth"/>
      <SONG SONG_NAME="When It Comes"/>
    <ALBUM PRICE="$9.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="Lordi">
    <ALBUM ALBUM_NAME="Arockalypse">
      <SONG SONG_NAME="Hard Rock Hallelujah"/>
      <SONG SONG_NAME="It Snows In Hell"/>
      <SONG SONG_NAME="Deadite Girls Gone Wild"/>
      <SONG SONG_NAME="Supermonstars"/> 
      <SONG SONG_NAME="Good To Be Bad"/>
    <ALBUM PRICE="$19.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="Pink"> 
    <ALBUM ALBUM_NAME="Fun House">
      <SONG SONG_NAME="So What"/>
      <SONG SONG_NAME="Sober"/>
      <SONG SONG_NAME="I Don&apos;t Believe You"/>
      <SONG SONG_NAME="One Foot Wrong"/>
      <SONG SONG_NAME="Please Don&apos;t Leave Me"/>
    <ALBUM PRICE="$22.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="The Smiths"> 
    <ALBUM ALBUM_NAME="The Queen Is Dead">
      <SONG SONG_NAME="Queen Is Dead (Take Me Back to Dear Old Blighty) [Medley]"/>
      <SONG SONG_NAME="Frankly, Mr. Shankly"/>
      <SONG SONG_NAME="I Know It&apos;s Over"/>
      <SONG SONG_NAME="Never Had No One Ever"/>
      <SONG SONG_NAME="Cemetry Gates"/>
    <ALBUM PRICE="$49.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="Simon &amp; Garfunkel">
    <ALBUM ALBUM_NAME="The Best of Simon &amp; Garfunkel">
      <SONG SONG_NAME="The Sound of Silence"/>
      <SONG SONG_NAME="Homeward Bound"/>
      <SONG SONG_NAME="I Am a Rock"/>
      <SONG SONG_NAME="The Dangling Conversation"/>
      <SONG SONG_NAME="Scarborough Fair"/>
    <ALBUM PRICE="$19.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="Veil of Maya">
    <ALBUM ALBUM_NAME="The Common Man&apos;s Collapse">
      <SONG SONG_NAME="Wounds"/>
      <SONG SONG_NAME="Crawl Back"/>
      <SONG SONG_NAME="Mark The Line"/>
      <SONG SONG_NAME="It&apos;s Not Safe To Swim Today"/>
      <SONG SONG_NAME="Entry Level Exit Wounds"/>
    <ALBUM PRICE="$19.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="Lil Wayne">
    <ALBUM ALBUM_NAME="Tha Carter">
      <SONG SONG_NAME="Walk In"/>
      <SONG SONG_NAME="Go DJ"/>
      <SONG SONG_NAME="This Is The Carter"/>
      <SONG SONG_NAME="BM J.R."/>
      <SONG SONG_NAME="I Miss My Dawg"/>
    <ALBUM PRICE="Free"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

  <BAND BAND_NAME="The Beatles">
    <ALBUM ALBUM_NAME="Revolver">
      <SONG SONG_NAME="Taxman Eleanor"/>
      <SONG SONG_NAME="Rigby"/>
      <SONG SONG_NAME="I&apos;m Only Sleeping"/>
      <SONG SONG_NAME="Love You To"/>
      <SONG SONG_NAME="Here, There and Everywhere"/>
    <ALBUM PRICE="$19.99 USD"/>
    <ALBUM ART=""/>
    </ALBUM>
  </BAND>

</FAVORITEMUSIC>
XSL File
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="FAVORITEMUSIC">

<HTML>
  <HEAD>
    <TITLE>
      CSIS-115B's Favorite Music
    </TITLE>
  </HEAD>
  <BODY>
    <xsl:for-each select="BAND">
      <H1>
        <xsl:value-of select="@BAND_NAME"/>
      </H1>
      <H3>
        <xsl:value-of select="ALBUM/@ALBUM_NAME"/>
      </H3>
      <H5>
        <xsl:value-of select="ALBUM/SONG/@SONG_NAME"/>
      </H5>
    </xsl:for-each>
  </BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
__________________
System: Life is a blast
CPU
Q6600
Motherboard
Gigabyte GA-P35-DS4
Memory
4x 1Gb Crucial Ballistix DDR2 800
Graphics Card
eVGA 8800GTX
Hard Drive
(1) 1TB Seagate & (1) 500GB Seagate
Sound Card
On-board
Power Supply
ITZ Tagan 800 Watt
Case
Antec 900
CPU cooling
Tuniq Tower
GPU cooling
Stock
OS
XP Pro
Monitor
Sceptre 24" LCD

Last edited by IaN- : 09-25-09 at 09:34 PM
IaN- is offline   Reply With Quote
Old 09-25-09   #2 (permalink)
Networking Nut
 
Lyoko's Avatar
 
intel nvidia

Join Date: Aug 2006
Posts: 2,198

Rep: 84 Lyoko is acknowledged by some
Unique Rep: 78
FAQs Submitted: 1
Trader Rating: 3
Default

Rewritten xml (with 3 bands) and xsl file.

page.xml
Code:
<?xml version ="1.0"?>
<?xml-stylesheet type="text/xsl" href="music.xsl"?>

<favoritemusic title="CSIS-115B's Favorite Music">

  <band band_name="Motley Crue" price="$19.99 USD" art="">
    <album album_name="Greatest Hits Package">
      <song>Live Wire</song>
      <song>Public Enemy #1</song>
      <song>Take Me To The Top</song>
      <song>Merry-Go-Round</song>
      <song>Piece Of Your Action</song>
    </album>
  </band>

  <band band_name="Daughtry">
    <album album_name="Leave This Town" price="$15.99 USD" art="">
      <song>You Don't Belong</song>
      <song>No Surprise</song>
      <song>Everytime You Turn Around</song>
      <song>Life After You</song>
      <song>What I Meant to Say</song>
    </album>
  </band>

  <band band_name="3Oh!3" price="$9.99 USD" art="">
    <album album_name="WANT">
      <song>Tapp</song>
      <song>Punk*****</song>
      <song>Don't Trust Me</song>
      <song>Chokechain</song>
      <song>I'm Not Your Boyfriend Baby</song>
    </album>
  </band>

</favoritemusic>
music.xsl
Code:
<?xml version="1.0"?>
	<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
		<xsl:template match="favoritemusic">
			<html>
			  <head>
			    <title>
	                    	<xsl:value-of select="//@title" />
			    </title>
			  </head>
			  <body>
			  	<xsl:for-each select="band">
			    		<h1><xsl:value-of select="@band_name" /></h1>
			    		<h3><xsl:value-of select="album/@album_name" /></h3>
			    		<ul>
						<xsl:for-each select="album/song">
							<li><xsl:value-of select="." /></li>
						</xsl:for-each>
			    		</ul>
			   	</xsl:for-each>
			  </body>
			</html>
		</xsl:template>
	</xsl:stylesheet>
Remember to keep your data (yes, even the title) in the xml file. Also, know when to close tags, make proper use of elements as well as attributes. Also, turn off caps lock

Here is a good XSL tutorial:
http://www.w3schools.com/xsl/

Good luck!

Last edited by Lyoko : 09-25-09 at 10:27 PM
Lyoko is offline   Reply With Quote
Old 09-26-09   #3 (permalink)
New to Overclock.net
 
IaN-'s Avatar
 
intel nvidia

Join Date: Sep 2007
Location: San Diego, CA
Posts: 35

Rep: 3 IaN- Unknown
Unique Rep: 2
Trader Rating: 0
Default

Thank you very much.
__________________
System: Life is a blast
CPU
Q6600
Motherboard
Gigabyte GA-P35-DS4
Memory
4x 1Gb Crucial Ballistix DDR2 800
Graphics Card
eVGA 8800GTX
Hard Drive
(1) 1TB Seagate & (1) 500GB Seagate
Sound Card
On-board
Power Supply
ITZ Tagan 800 Watt
Case
Antec 900
CPU cooling
Tuniq Tower
GPU cooling
Stock
OS
XP Pro
Monitor
Sceptre 24" LCD
IaN- is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 08:11 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.12117 seconds with 8 queries