GOW

From ICO wiki
Revision as of 21:14, 24 March 2013 by Hkroonsa (talk | contribs)
Jump to navigationJump to search

Team GOW

"Kodutöö_aines_"Võrgurakendused_II:_hajussüsteemide_ehitamine"_2013"

  • Heimar Kroonsaare
  • Silver Vanamets

XML

<?xml version="1.0" encoding="utf-8"?>
<games>
  <platform id="1" name="PC">
  <genre id="1" name="Strategy">
    <subgenre id ="1" name="RTS">
    <game id="1" name="Command and Conquer" year="1995" publisher="Electronic Arts">
      <info>          
        <requirements>
          <CPU>"-"</CPU>
          <GPU>"-"</GPU>
          <RAM>"-"</RAM>                      
        </requirements>
      </info>
    </game>
    </subgenre>
  </genre>
  </platform>  
  <platform id="2" name="XBox360">
    <genre id="2" name="Action">
      <subgenre id ="2" name="FPS">
        <game id="2" name="Halo 4" year="2012" publisher="Microsoft Studios">
          <info>            
            <requirements>
              <CPU>"-"</CPU>
              <GPU>"-"</GPU>
              <RAM>"-"</RAM>
            </requirements>
          </info>
        </game>
      </subgenre>
    </genre>
  </platform>  
  <platform id="3" name="PS3">
    <genre id="2" name="Action">
      <subgenre id ="3" name="TPS">
        <game id="5" name="Grand Theft Auto 4" year="2008" publisher="Take-Two Interactive">
          <info>            
            <requirements>
              <CPU>"-"</CPU>
              <GPU>"-"</GPU>
              <RAM>"-"</RAM>
            </requirements>
          </info>
        </game>
      </subgenre>
    </genre>
  </platform>  
  <platform id="4" name="Wii">
    <genre id="3" name="Sports">
      <subgenre id ="1" name="Football">
        <game id="10" name="FIFA 13" year="2012" publisher="Electronic Arts">
          <info>            
            <requirements>
              <CPU>"-"</CPU>
              <GPU>"-"</GPU>
              <RAM>"-"</RAM>
            </requirements>
          </info>
        </game>
      </subgenre>
    </genre>
  </platform>  
</games>

XML schema

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="games">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="platform">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="genre">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="subgenre">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="game">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="info">
                                  <xs:complexType>
                                    <xs:sequence>
                                      <xs:element name="requirements">
                                        <xs:complexType>
                                          <xs:sequence>
                                            <xs:element name="CPU" type="xs:string" />
                                            <xs:element name="GPU" type="xs:string" />
                                            <xs:element name="RAM" type="xs:string" />
                                          </xs:sequence>
                                        </xs:complexType>
                                      </xs:element>
                                    </xs:sequence>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                              <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                              <xs:attribute name="name" type="xs:string" use="required" />
                              <xs:attribute name="year" type="xs:unsignedShort" use="required" />
                              <xs:attribute name="publisher" type="xs:string" use="required" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                        <xs:attribute name="name" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                  <xs:attribute name="name" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:unsignedByte" use="required" />
            <xs:attribute name="name" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT

<?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>
        <h2>Games</h2>
        <table border="1">
          <tr bgcolor="#9acd32">
            <th>Name</th>
            <th>Year</th>
            <th>Publisher</th>
          </tr>
          <xsl:for-each select="games/platform/genre/subgenre/game">
            <tr>
              <td>
                <xsl:value-of select="@name"/>
              </td>
              <td>
                <xsl:value-of select="@year"/>
              </td>
              <td>
                <xsl:value-of select="@publisher"/>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>