Meeskond "Kujuneb"

From ICO wiki
Revision as of 17:03, 15 April 2011 by Rvali (talk | contribs) (→‎XSLT)
Jump to navigationJump to search

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"?>
<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;
          }

          h1{
          color: #19212b;
          }

          table{
          font-size: 12px;
          border-collapse: collapse;
          }

          .mainTable{
          border: 1px solid #98bf21;
          }

          .mainTable th{
          padding:3px 10px 3px 10px;
          border: 1px solid #98bf21;
          background: #A7C942;
          color: #FFFFFF;
          }
          .mainTable tr {
          background: #FFFFFF;
          color: #000000;
          }

          .mainTable td{

          text-align: center;
          padding: 3px;
          border:1px solid #98bf21;
          }
          .mainTable td:hover {
          background-color: #000000;
          }
          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>
                    <xsl:attribute name="src">
                      <xsl:text>http://www.upenn.edu/pennnews/current/images/icons/youtube-64.png</xsl:text>
                    </xsl:attribute>
                  </img>
                </a>
              </td>

            </tr>        
             
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>