Yksikyritus

From ICO wiki
Jump to navigationJump to search


Meeskond "Yksikyritus"
Õppeaine: Võrgurakendused II: hajussüsteemide ehitamine
Meeskonnaliige: Kaidi Parman
Juhendaja: Mait Poska
Semester: 2016 kevad

= Idee

Raamatupood, mis otsib raamatud Amazonist. Idee on teha projekt prooviülesande baasil, mille sain ühest IT ettevõttest.

XML

XML andmefail

<?xml version="1.0" encoding="utf-8" ?>
<books>
  <book id="1">
    <category id="1"><![CDATA[Science Fiction]]></category>
    <title><![CDATA[The Hunger Games]]></title>
    <authors>
      <author id="1">
        <firstName><![CDATA[Suzanne]]></firstName>
        <lastName><![CDATA[Collins]]></lastName> 
      </author>
     </authors>
    <formats>
      <format>
      <formatType id="1"><![CDATA[Kindle Edition]]></formatType>
        <releaseDate><![CDATA[01.03.2012]]></releaseDate>
        <fileSize><![CDATA[1213 KB]]></fileSize>
        <printLength><![CDATA[387 pages]]></printLength>
        <language><![CDATA[English]]></language>
        <prices>
          <new currency="GBP"><![CDATA[3.66]]></new>
         </prices>
      </format>
      <format>
      <formatType id="2"><![CDATA[Hardcover]]></formatType>
        <releaseDate><![CDATA[02.09.2009]]></releaseDate>
        <pages><![CDATA[485]]></pages>
        <language><![CDATA[English]]></language>
        <productDimensions ><![CDATA[2.5 x 14.6 x 22.2 cm]]></productDimensions>
        <prices>
          <new currency="GBP"><![CDATA[16.49]]></new>
          <used currency="GBP"><![CDATA[11.33]]></used>
        </prices>
      </format>
      <format>
      <formatType id="3"><![CDATA[Paperback]]></formatType>
        <releaseDate><![CDATA[01.12.2011]]></releaseDate>
        <pages><![CDATA[464]]></pages>
        <language><![CDATA[English]]></language>
        <productDimensions ><![CDATA[12.5 x 2.8 x 19.8 cm]]></productDimensions>
        <prices>
         <new currency="GBP"><![CDATA[3.85]]></new>
         <used currency="GBP"><![CDATA[0.01]]></used>
        </prices>
      </format>
      <format>
        <formatType id="4"><![CDATA[Audio Download]]></formatType>
        <releaseDate><![CDATA[01.10.2008]]></releaseDate>
        <listeningLength><![CDATA[11 hours and 14 minutes]]></listeningLength>
        <language><![CDATA[English]]></language>
        <prices>
          <new currency="GBP"><![CDATA[FREE]]></new>
        </prices>
      </format>
    </formats>
    <introduction>
      <![CDATA[Sixteen-year-old Katniss Everdeen regards it as a death sentence 
      when she is forced to represent her district in the annual Hunger Games, 
      a fight to the death on live TV. But Katniss has been close to death 
      before-and survival, for her, is second nature. The Hunger Games is a 
      searing novel set in a future with unsettling parallels to our present. 
      Welcome to the deadliest reality TV show ever...]]>
    </introduction> 
  </book>
  <book id="2">
    <category id="2"><![CDATA[Computing & Internet]]></category>
    <title><![CDATA[Design patterns : elements of reusable object-oriented software]]></title>
    <authors>
      <author id="2">
        <firstName><![CDATA[Erich]]></firstName>
        <lastName><![CDATA[Gamma]]></lastName>
      </author>
      <author id="3">
        <firstName><![CDATA[Richard]]></firstName>
        <lastName><![CDATA[Helm]]></lastName>
      </author>
      <author id="4">
        <firstName><![CDATA[Ralph]]></firstName>
        <lastName><![CDATA[Johnson]]></lastName>
      </author>
      <author id="5">
        <firstName><![CDATA[John]]></firstName>
        <lastName><![CDATA[Vlissides]]></lastName>
      </author>
    </authors>
    <formats>
      <format>
        <formatType id="1"><![CDATA[Kindle Edition]]></formatType>
        <releaseDate><![CDATA[31.10.1994]]></releaseDate>
        <fileSize><![CDATA[19069 KB]]></fileSize>
        <printLenght><![CDATA[395 pages]]></printLenght>
        <language><![CDATA[English]]></language>
        <prices>
          <new currency="GBP"><![CDATA[20.30]]></new>
        </prices>
      </format>
      <format>
        <formatType id="2"><![CDATA[Hardcover]]></formatType>
        <releaseDate><![CDATA[31.10.1994]]></releaseDate>
        <pages><![CDATA[416]]></pages>
        <language><![CDATA[English]]></language>
        <productDimensions><![CDATA[19.3 x 2.5 x 23.6 cm]]></productDimensions>
        <prices>
          <new currency="GBP"><![CDATA[21.35]]></new>
          <used currency="GBP"><![CDATA[16.30]]></used>
        </prices>
      </format>
      <format>
        <formatType id="3"><![CDATA[Paperback]]></formatType>
        <releaseDate><![CDATA[2015]]></releaseDate>
        <language><![CDATA[English]]></language>
        <productDimensions><![CDATA[21.4 x 14.9 x 1.9 cm]]></productDimensions>
        <prices>
          <new currency="GBP"><![CDATA[12.15]]></new>
          <used currency="GBP"><![CDATA[13.37]]></used>
        </prices>
      </format>
      <format>
        <formatType id="5"><![CDATA[CD-ROM - Audiobook]]></formatType>
        <releaseDate><![CDATA[21.05.1998]]></releaseDate>
        <language><![CDATA[English]]></language>
        <productDimensions><![CDATA[19.2 x 2.1 x 23.6 cm]]></productDimensions>
        <prices>
          <new currency="GBP"><![CDATA[29.88]]></new>
          <used currency="GBP"><![CDATA[24.97]]></used>
        </prices>
      </format>
    </formats>
    <introduction>
      <![CDATA[Capturing a wealth of experience about the design of object-oriented software, 
      four top-notch designers present a catalog of simple and succinct solutions to commonly 
      occurring design problems. Previously undocumented, these 23 patterns allow designers 
      to create more flexible, elegant, and ultimately reusable designs without having to 
      rediscover the design solutions themselves.

      The authors begin by describing what patterns are and how they can help you design 
      object-oriented software. They then go on to systematically name, explain, evaluate, 
      and catalog recurring designs in object-oriented systems. With Design Patterns as 
      your guide, you will learn how these important patterns fit into the software development 
      process, and how you can leverage them to solve your own design problems most efficiently.

      Each pattern describes the circumstances in which it is applicable, when it can be applied 
      in view of other design constraints, and the consequences and trade-offs of using the pattern 
      within a larger design. All patterns are compiled from real systems and are based on real-world 
      examples. Each pattern also includes code that demonstrates how it may be implemented in 
      object-oriented programming languages like C++ or Smalltalk.]]></introduction>
  </book>
</books>

XSD (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="books">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="book">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="category">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element name="title" type="xs:string" />
              <xs:element name="authors">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="author">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="firstName" type="xs:string" />
                          <xs:element name="lastName" 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:element name="formats">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="format">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="formatType">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="releaseDate" type="xs:string" />
                          <xs:element minOccurs="0" name="listeningLength" type="xs:string" />
                          <xs:element minOccurs="0" name="pages" type="xs:string" />
                          <xs:element minOccurs="0" name="fileSize" type="xs:string" />
                          <xs:element minOccurs="0" name="printLenght" type="xs:string" />
                          <xs:element minOccurs="0" name="printLength" type="xs:string" />
                          <xs:element name="language" type="xs:string" />
                          <xs:element minOccurs="0" name="productDimensions" type="xs:string" />
                          <xs:element name="prices">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="new">
                                  <xs:complexType>
                                    <xs:simpleContent>
                                      <xs:extension base="xs:string">
                                        <xs:attribute name="currency" type="xs:string" use="required" />
                                      </xs:extension>
                                    </xs:simpleContent>
                                  </xs:complexType>
                                </xs:element>
                                <xs:element minOccurs="0" name="used">
                                  <xs:complexType>
                                    <xs:simpleContent>
                                      <xs:extension base="xs:string">
                                        <xs:attribute name="currency" type="xs:string" use="required" />
                                      </xs:extension>
                                    </xs:simpleContent>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="introduction" 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"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/">
    <html>
      <body>
        <h2>Raamatute nimekiri</h2>
        <table border="1" >
          <tr bgcolor="green">
            <th style="text-align:left">Author(s)</th>
            <th style="text-align:left;width:420px">Title</th>
            <th style="text-align:left">Introduction</th>
          </tr>
          <xsl:for-each select="books/book">
            <tr>
              <td>
                <xsl:value-of select="authors"/>
              </td>
              <td>
                <xsl:value-of select="title"/>
              </td>
              <td>
                <xsl:value-of select="introduction"/>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="html" indent="yes"/>

  <xsl:template match="/">
    <html>
      <body>
        <h2>Formaadid, mille pikkus on üle 400 lehekülje</h2>
        <table border="1">
          <tr bgcolor="green">
            <th style="text-align:left">Author(s)</th>
            <th style="text-align:left">Title</th>
            <th style="text-align:left">Format</th>
            <th style="text-align:left">Pages</th>
          </tr>
          <xsl:for-each select="books/book">
           <xsl:if test="formats/format/pages > 400">
            <tr>
              <td>
                <xsl:value-of select="authors"/>
              </td>
              <td>
                <xsl:value-of select="title"/>
              </td>
              <td>
                <xsl:value-of select="formats/format/formatType"/>
              </td>
              <td>
                <xsl:value-of select="formats/format/pages"/>
              </td>
            </tr>
           </xsl:if>
          </xsl:for-each>
        </table>
      </body>
    </html>
    </xsl:template>
</xsl:stylesheet>

Logi

20.märts 2016

Wiki lehe loomine. XML'i ja XSD lisamine lehele.

25.märts 2016

Proovisin XSLT faile kokku panna. Ei tea, kas XML on valesti tehtud või lihtsalt pole piisavalt arukas, aga midagi vapustavat välja ei tulnud. Olen päris pettunud.