|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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>
|
|
#3
|
|||
|
|||
|
Thanks, I acctualy figured it out last night but thanks anyway
|
|
#4
|
|||
|
|||
|
Quote:
Thats always the way. ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > problem with xsl template |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|