Meeskond "Kujuneb": Difference between revisions
From ICO wiki
Jump to navigationJump to search
m →XML: Üks line indent oli paha, nüüd peaks treppimine korras olema |
→XSLT: Pisemad iluvead (reavahetused, tühikud, jms.) ja asjad |
||
Line 50: | Line 50: | ||
===XSLT=== | ===XSLT=== | ||
<source lang="xml"> | <source lang="xml"> | ||
<?xml version="1.0"?> | <?xml version="1.0" encoding="utf-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
<xsl:template match="/"> | <xsl:template match="/"> | ||
Line 57: | Line 57: | ||
<title>Muusikakogu</title> | <title>Muusikakogu</title> | ||
<style type="text/css"> | <style type="text/css"> | ||
body{ | body { | ||
font-family: Arial, Verdana; | |||
} | } | ||
table { | |||
font-size: 12px; | |||
border-collapse: collapse; | |||
} | } | ||
.mainTable { | |||
border: 1px solid #98bf21; | |||
} | } | ||
.mainTable{ | .mainTable th { | ||
padding: 3px 10px 3px 10px; | |||
border: 1px solid #98bf21; | |||
background-color: #A7C942; | |||
color: #FFFFFF; | |||
} | } | ||
.mainTable tr { | .mainTable tr { | ||
background-color: #FFFFFF; | |||
} | } | ||
.mainTable td{ | .mainTable td { | ||
text-align: center; | |||
padding: 3px; | |||
border: 1px solid #98bf21; | |||
} | |||
a, a:hover, a:active, a:visited { | |||
color: #000000; | |||
a, a:hover,a:active,a:visited { | |||
} | } | ||
a img { | a img { | ||
border: none; | border: none; | ||
} | |||
</style> | </style> | ||
</head> | </head> | ||
Line 106: | Line 99: | ||
<h1>Albumid</h1> | <h1>Albumid</h1> | ||
<table class="mainTable"> | <table class="mainTable"> | ||
<tr> | <tr> | ||
<th>Artist</th> | <th>Artist</th> | ||
<th>Plaat</th> | <th>Plaat</th> | ||
Line 119: | Line 112: | ||
<xsl:if test="position() mod 2 =0"> | <xsl:if test="position() mod 2 =0"> | ||
<xsl:attribute name="style"> | <xsl:attribute name="style"> | ||
background-color:#EAF2D3; | background-color: #EAF2D3; | ||
</xsl:attribute> | </xsl:attribute> | ||
</xsl:if> | </xsl:if> | ||
Line 137: | Line 130: | ||
<xsl:value-of select="songs"/> | <xsl:value-of select="songs"/> | ||
</td> | </td> | ||
<td> | <td> | ||
<img width="100" height="100"> | <img width="100" height="100"> | ||
Line 150: | Line 142: | ||
<xsl:text>http://www.youtube.com/results?search_query=</xsl:text><xsl:value-of select="artist"/>+<xsl:value-of select="plaat"/> | <xsl:text>http://www.youtube.com/results?search_query=</xsl:text><xsl:value-of select="artist"/>+<xsl:value-of select="plaat"/> | ||
</xsl:attribute> | </xsl:attribute> | ||
<img | <img src="http://www.upload.ee/image/1288041/youtube-badge-64x64.png"> | ||
</img> | </img> | ||
</a> | </a> | ||
</td> | </td> | ||
</tr> | </tr> | ||
</xsl:for-each> | </xsl:for-each> | ||
</table> | </table> | ||
Line 166: | Line 153: | ||
</xsl:template> | </xsl:template> | ||
</xsl:stylesheet> | </xsl:stylesheet> | ||
</source> | </source> | ||
==Kujundus== | ==Kujundus== | ||
[[File:Muusikakogu_naidis.png]] | [[File:Muusikakogu_naidis.png]] |
Revision as of 19:45, 21 April 2011
XML
<?xml version="1.0" encoding="utf-8"?>
<albumid>
<album id="1">
<artist>Queen</artist>
<plaat>Greatest Hits</plaat>
<aasta>2005</aasta>
<genre>Pop</genre>
<songs>15</songs>
<pilt>http://rpmedia.ask.com/ts?u=/wikipedia/en/thumb/3/3f/RedGreatestHitsQuennalbumcover.png/180px-RedGreatestHitsQuennalbumcover.png</pilt>
</album>
<album id="2">
<artist>Madonna</artist>
<plaat>American Life</plaat>
<aasta>2002</aasta>
<genre>Rap</genre>
<songs>19</songs>
<pilt>http://www.clubbingmagazine.com/images/reviews/madonna%20single.jpg</pilt>
</album>
</albumid>
XSD
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="albumid">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="album">
<xs:complexType>
<xs:sequence>
<xs:element name="artist" type="xs:string" />
<xs:element name="plaat" type="xs:string" />
<xs:element name="aasta" type="xs:unsignedShort" />
<xs:element name="genre" type="xs:string" />
<xs:element name="songs" type="xs:unsignedByte" />
<xs:element name="pilt" type="xs:string" />
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedByte" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Muusikakogu</title>
<style type="text/css">
body {
font-family: Arial, Verdana;
}
table {
font-size: 12px;
border-collapse: collapse;
}
.mainTable {
border: 1px solid #98bf21;
}
.mainTable th {
padding: 3px 10px 3px 10px;
border: 1px solid #98bf21;
background-color: #A7C942;
color: #FFFFFF;
}
.mainTable tr {
background-color: #FFFFFF;
}
.mainTable td {
text-align: center;
padding: 3px;
border: 1px solid #98bf21;
}
a, a:hover, a:active, a:visited {
color: #000000;
}
a img {
border: none;
}
</style>
</head>
<body>
<h1>Albumid</h1>
<table class="mainTable">
<tr>
<th>Artist</th>
<th>Plaat</th>
<th>Aasta</th>
<th>Genre</th>
<th>Laule</th>
<th>Pilt</th>
<th>YouTube</th>
</tr>
<xsl:for-each select="albumid/album">
<tr>
<xsl:if test="position() mod 2 =0">
<xsl:attribute name="style">
background-color: #EAF2D3;
</xsl:attribute>
</xsl:if>
<td>
<xsl:value-of select="artist"/>
</td>
<td>
<xsl:value-of select="plaat"/>
</td>
<td>
<xsl:value-of select="aasta"/>
</td>
<td>
<xsl:value-of select="genre"/>
</td>
<td>
<xsl:value-of select="songs"/>
</td>
<td>
<img width="100" height="100">
<xsl:attribute name="src">
<xsl:value-of select="pilt"/>
</xsl:attribute>
</img>
</td>
<td>
<a>
<xsl:attribute name="href">
<xsl:text>http://www.youtube.com/results?search_query=</xsl:text><xsl:value-of select="artist"/>+<xsl:value-of select="plaat"/>
</xsl:attribute>
<img src="http://www.upload.ee/image/1288041/youtube-badge-64x64.png">
</img>
</a>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>