xml / xslxml файл
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="template.xsl"?>
<artists>
<artist id='1'>
<artist_name>Alai Oli</artist_name>
<artist_image>img/alai_oli_img.jpg</artist_image>
<albums>
<album id='1'>
<album_name>Да, бро?</album_name>
<year>2007</year>
<songs>
<song id='1'>
<song_name>Солнце и Луна</song_name>
<song_time>00:04:12</song_time>
<song_genre>Регги</song_genre>
<song_url>content/alai_oli/2007_da_bro/Solnce_i_Luna.mp3</song_url>
</song>
<song id='2'>
<song_name>Гавана</song_name>
<song_time>00:02:47</song_time>
<song_genre>Регги</song_genre>
<song_url>content/alai_oli/2007_da_bro/Gavana.mp3</song_url>
</song>
<song id='3'>
<song_name>Джаманы</song_name>
<song_time>00:01:52</song_time>
<song_url>content/alai_oli/2007_da_bro/Dzhamany.mp3</song_url>
</song>
<song id='4'>
<song_name>Не Отпускай Тепло</song_name>
<song_time>00:05:07</song_time>
<song_url>content/alai_oli/2007_da_bro/Ne_Otpuskaj_Teplo.mp3</song_url>
</song>
<song id='5'>
<song_name>Февраль</song_name>
<song_time>00:02:53</song_time>
<song_url>content/alai_oli/2007_da_bro/Fevral.mp3</song_url>
</song>
<song id='6'>
<song_name>Греция</song_name>
<song_time>00:04:51</song_time>
<song_genre>Регги</song_genre>
<song_url>content/alai_oli/2007_da_bro/Grecija.mp3</song_url>
</song>
</songs>
</album>
</albums>
</artist>
<artist id='2'>
<artist_name>Depeche Mode</artist_name>
<artist_image>img/depeche_mode_img.jpg</artist_image>
<albums>
<album id='2'>
<album_name>Violator</album_name>
<year>1990</year>
<songs>
<song id='7'>
<song_name>World in My Eyes</song_name>
<song_time>00:04:26</song_time>
<song_url>content/depeche_mode/1990_violator/World_in_My_Eyes.mp3</song_url>
</song>
<song id='8'>
<song_name>Personal Jesus</song_name>
<song_time>00:04:56</song_time>
<song_genre>Рок</song_genre>
<song_url>content/depeche_mode/1990_violator/Personal_Jesus.mp3</song_url>
</song>
<song id='9'>
<song_name>Halo</song_name>
<song_time>00:04:30</song_time>
<song_genre>Electronica</song_genre>
<song_url>content/depeche_mode/1990_violator/Halo.mp3</song_url>
</song>
<song id='10'>
<song_name>Enjoy the Silence</song_name>
<song_time>00:06:12</song_time>
<song_genre>Electronica</song_genre>
<song_url>content/depeche_mode/1990_violator/Enjoy_the_Silence.mp3</song_url>
</song>
<song id='11'>
<song_name>Blue Dress</song_name>
<song_time>00:05:42</song_time>
<song_url>content/depeche_mode/1990_violator/Blue_Dress.mp3</song_url>
</song>
</songs>
</album>
</albums>
</artist>
<artist id='3'>
<artist_name>Metallica</artist_name>
<artist_image>img/metallica_img.jpeg</artist_image>
<albums>
<album id='3'>
<album_name>Master Of Puppets</album_name>
<year>1986</year>
<songs>
<song id='15'>
<song_name>Battery</song_name>
<song_time>00:05:12</song_time>
<song_genre>Рок</song_genre>
<song_url>content/metallica/1986_Master_Of_Puppets/Battery.mp3</song_url>
</song>
</songs>
</album>
<album id='4'>
<album_name>Best Ballads</album_name>
<year>1998</year>
<songs>
<song id='12'>
<song_name>The Unforgiven</song_name>
<song_time>00:06:26</song_time>
<song_url>content/metallica/1998_best_ballads/The_Unforgiven.mp3</song_url>
</song>
<song id='13'>
<song_name>One</song_name>
<song_time>00:07:26</song_time>
<song_genre>Рок</song_genre>
<song_url>content/metallica/1998_best_ballads/One.mp3</song_url>
</song>
<song id='14'>
<song_name>Fade To Black</song_name>
<song_time>00:06:55</song_time>
<song_genre>Рок</song_genre>
<song_url>content/metallica/1998_best_ballads/Fade_To_Black.mp3</song_url>
</song>
</songs>
</album>
</albums>
</artist>
</artists>
xsl
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
<xsl:stylesheet version="2.0"
xmlns:xs= "http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
encoding="UTF-8"
indent="no"
media-type="text/xml"
doctype-public="-//W3C//DTD XHTML 1.1//EN"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
/>
<xsl:template match="/artists">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head>
<title>Аудиотека</title>
<style>
body,html{padding:o;marging:0;background: rgb(228, 228, 228);}
div{padding:5px;}
.content{margin:0 auto;max-width: 500px;}
.title{background: rgb(240, 240, 240);font: 20px sans-serif;}
.title.artist{color:white;border-right: 3px solid rgb(255, 112, 0);margin: 0 -3px 0 3px;height: 150px;text-shadow: 1px 1px 2px black;}
.title.albums{color:rgb(163, 163, 163);}
.album{border-left: 3px solid rgb(163, 163, 163);}
.title.songs{color:rgb(0, 194, 93);}
.song{border-left: 3px solid rgb(0, 194, 93);}
.album span, .song span {font-weight: bold;font-style: normal;}
.title span{font-style: normal;}
span{font-style: italic;}
.item{margin:0 0 0 3px;background: rgb(255, 255, 255);}
.img{height: 150px;margin-top: -10px;}
</style>
</head>
<body>
<div class="content">
<xsl:apply-templates select="//artist[@id = '1']" mode="line" />
</div>
</body>
</html>
</xsl:template>
<xsl:template match="*" mode="line">
<div class="item">
<xsl:if test="name() = 'albums'">
<xsl:attribute name="class">title albums</xsl:attribute>
</xsl:if>
<xsl:if test="name() = 'songs'">
<xsl:attribute name="class">title songs</xsl:attribute>
</xsl:if>
<xsl:if test="name() = 'artist'">
<xsl:attribute name="class">title artist</xsl:attribute>
</xsl:if>
<xsl:if test="name() = 'album'">
<xsl:attribute name="class">album</xsl:attribute>
</xsl:if>
<xsl:if test="name() = 'song'">
<xsl:attribute name="class">song</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="." mode="item"/>
</div>
<xsl:apply-templates select="./*" mode="line"/>
</xsl:template>
<xsl:template match="*" mode="item">
<xsl:apply-templates select="artist_image" mode="img"/>
<span><xsl:value-of select="name()"/>: </span>
<xsl:value-of select="self::*/text()"/>
<xsl:for-each select="attribute::*">
<xsl:value-of select="name()"/>
<xsl:text> = </xsl:text>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
<xsl:template match="artists/artist/artist_image" mode="img">
<xsl:attribute name="style">
<xsl:text>background: url('</xsl:text>
<xsl:value-of select="self::*/text()"/>
<xsl:text>') 50% 0;</xsl:text>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Мой вопрос в бОльшей степени касается строки
1.
<xsl:apply-templates select="//artist[@id = '1']" mode="line" />
в шаблоне, а именно, возможно ли написать условие так, что бы вывести на экран, скажем, первого исполнителя( уже в выборке ) - его первый альбом - первую песню альбома?
А если нет, то как это лучше реализовать?