Proovitud abielu

From ICO wiki
Revision as of 22:49, 20 March 2017 by Bpoldoja (talk | contribs)
Jump to navigationJump to search

Kodutöö aines "Võrgurakendused II: hajussüsteemide ehitamine"

Meeskond "Proovitud abielu"

  • Berit Põldoja
  • Elina Kuldkepp


XML/XSD/XSLT

XML

 <?xml version="1.0" encoding="UTF-8"?>
<Bookstores>
  <Bookstore id="1" country="Spain">
    <Name>Señorita</Name>
    <Book category="Crime" quantity="50" language="english" pages="250">
      <Title><![CDATA[The Case of the Counterfeit Eye]]></Title>
      <Description><![CDATA[After wealthy businessman Hartley Bassetts apparent suicide, Perry Mason discovers too many suspects who may have wanted him dead to believe the obvious evidence of a suicide note and three guns near the body.]]></Description>
      <Author gender="Male">
        <FirstName>Erle Stanley</FirstName>
        <LastName>Gardner</LastName>
        <BirthYear>1889</BirthYear>
        <Country>USA</Country>
      </Author>
      <ReleaseDate>
        <Day>20</Day>
        <Month>March</Month>
        <Year>1928</Year>
      </ReleaseDate>
      <Price>30.50</Price>
      <Location>Madrid</Location>
    </Book>
    <Book category="Drama" quantity="20" language="english" pages="150">
      <Title><![CDATA[Beating hearts.]]></Title>
      <Description><![CDATA[Beating Hearts maintains that sentence or ability to have subjective experiences.]]></Description>
      <Author gender="Female">
        <FirstName>Hannah</FirstName>
        <LastName>Cole</LastName>
        <BirthYear>1985</BirthYear>
        <Country>USA</Country>
      </Author>
      <ReleaseDate>
        <Day>14</Day>
        <Month>May</Month>
        <Year>2005</Year>
      </ReleaseDate>
      <Price>20</Price>
      <Location>Sevilla</Location>
    </Book>
  </Bookstore>
  <Bookstore id="2" country="France">
    <Name>Mademoiselle</Name>
    <Book category="Romance" quantity="43" language="english" pages="400">
      <Title><![CDATA[The Case of the Counterfeit Eye]]></Title>
      <Description><![CDATA[After wealthy businessman Hartley Bassetts apparent suicide, Perry Mason discovers too many suspects who may have wanted him dead to believe the obvious evidence of a suicide note and three guns near the body.]]></Description>
      <Author gender="Woman">
        <FirstName>Charlotte</FirstName>
        <LastName> Brontë</LastName>
        <BirthYear>1816</BirthYear>
        <Country>England</Country>
      </Author>
      <ReleaseDate>
        <Day>16</Day>
        <Month>October</Month>
        <Year>1847</Year>
      </ReleaseDate>
      <Price>20.99</Price>
      <Location>Paris</Location>
    </Book>
    <Book category="Crime" quantity="50" language="english" pages="250">
      <Title><![CDATA[The Case of the Counterfeit Eye]]></Title>
      <Description><![CDATA[When a murdered man is found in the home of shady insurance adjustor Walter Prescott, a simple divorce case turns into a courtroom puzzler, as Perry Mason follows the clues to catch a killer. Reissue.]]></Description>
      <Author gender="Male">
        <FirstName>Erle Stanley</FirstName>
        <LastName>Gardner</LastName>
        <BirthYear>1889</BirthYear>
        <Country>USA</Country>
      </Author>
      <ReleaseDate>
        <Day>21</Day>
        <Month>September</Month>
        <Year>1920</Year>
      </ReleaseDate>
      <Price>25</Price>
      <Location>Paris</Location>
    </Book>
    <Book category="Sci-fi" quantity="50" language="france" pages="450">
      <Title><![CDATA[Something suspicious]]></Title>
      <Description><![CDATA[Something happened]]></Description>
      <Author gender="Male">
        <FirstName>Erle Stanley</FirstName>
        <LastName>Gardner</LastName>
        <BirthYear>1889</BirthYear>
        <Country>USA</Country>
      </Author>
      <ReleaseDate>
        <Day>12</Day>
        <Month>August</Month>
        <Year>1905</Year>
      </ReleaseDate>
      <Price>27.99</Price>
      <Location>Nice</Location>
    </Book>
  </Bookstore>
  <Bookstore id="3" country="Great Britain">
    <Name>Fraŭlino</Name>
    <Book category="Comedy" quantity="25" language="english" pages="150">
      <Title><![CDATA[This was fun.]]></Title>
      <Description><![CDATA[So much fun stuff happens. Must read.]]></Description>
      <Author gender="Woman">
        <FirstName>Berit</FirstName>
        <LastName>Põldoja</LastName>
        <BirthYear>1996</BirthYear>
        <Country>Estonia</Country>
      </Author>
      <ReleaseDate>
        <Day>17</Day>
        <Month>May</Month>
        <Year>2019</Year>
      </ReleaseDate>
      <Price>35.99</Price>
      <Location>London</Location>
    </Book>
    <Book category="Drama" quantity="15" language="english" pages="450">
      <Title><![CDATA[Sad Woman.]]></Title>
      <Description><![CDATA[Woman is very sad.]]></Description>
      <Author gender="Woman">
        <FirstName>Elina</FirstName>
        <LastName>Kuldkepp</LastName>
        <BirthYear>1994</BirthYear>
        <Country>Estonia</Country>
      </Author>
      <ReleaseDate>
        <Day>30</Day>
        <Month>October</Month>
        <Year>2020</Year>
      </ReleaseDate>
      <Price>20</Price>
      <Location>Oxford</Location>
    </Book>
  </Bookstore>
</Bookstores>

XSD

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/XMLSchema1.xsd" xmlns:mstns="http://tempuri.org/XMLSchema1.xsd" 
id="XMLSchema1" targetNamespace="http://tempuri.org/XMLSchema1.xsd" elementFormDefault="qualified">
  <xs:element name="Bookstores">
    <xs:complexType>
      <xs:element name="Bookstore" type="xs:string">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Name" type="xs:string" />
            <xs:element name="Book">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Title" type="xs:string" />
                  <xs:element name="Description" type="xs:string" />
                  <xs:element name="Author" type="xs:string">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element name="FirstName" type="xs:string" />
                        <xs:element name="LastName" type="xs:string" />
                        <xs:element name="BirthYear" type="xs:string" />
                        <xs:element name="Country" type="xs:string" />
                      </xs:sequence>
                      <xs:attribute name="gender" type="xs:string" use="required" />
                    </xs:complexType>
                  </xs:element>
                  <xs:element name="ReleaseDate" type="xs:string">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element name="Day" type="xs:datetime" />
                        <xs:element name="Month" type="xs:datetime" />
                        <xs:element name="Year" type="xs:datetime" />
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                  <xs:element name="Price" type="xs:decimal" />
                  <xs:element name="Location" type="xs:string" />
                </xs:sequence>
                <xs:attribute name="category" type="xs:string" use="required" />
                <xs:attribute name="quantity" type="xs:string" use="required" />
                <xs:attribute name="language" type="xs:string" use="required" />
                <xs:attribute name="pages" type="xs:int" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="id" type="xs:string" use="required" />
          <xs:attribute name="country" type="xs:string" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT HTML

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0" exclude-result-prefixes="msxsl">
  <xsl:output method="html" indent="yes" />
  <xsl:template match="/">
    <html>
      <head>
        <title>Raamatupoed</title>
      </head>
      <body>
        <h1>Raamatupoed</h1>
      </body>
      <table border="1">
        <tr bgcolor="#9acd32">
          <th>Raamatupood ja raamatud</th>
          <th>Kirjeldus</th>
          <th>Info</th>
        </tr>
        <xsl:for-each select="Bookstores/Bookstore">
          <tr>
            <td bgcolor="#9acd32">
              <xsl:value-of select="Name" />
            </td>
            <xsl:for-each select="Book">
              <tr>
                <td>
                  <xsl:value-of select="Title" />
                </td>
                <td>
                  <xsl:value-of select="Description" />
                </td>
                <td>
                  <xsl:value-of select="Author" />
                </td>
              </tr>
            </xsl:for-each>
          </tr>
        </xsl:for-each>
      </table>
      <table border="1">
        <tr bgcolor="#9acd32">
          <th>Sugu</th>
          <th>Eesnimi</th>
          <th>Perekonnanimi</th>
          <th>Riik</th>
          <th>Sünniaasta</th>
        </tr>
        <xsl:for-each select="Bookstores/Bookstore/Book/Author">
          <tr>
            <xsl:if test="@gender='Woman'">
              <xsl:if test="Country='Estonia'">
                <td>
                  <xsl:value-of select="@gender" />
                </td>
                <td>
                  <xsl:value-of select="FirstName" />
                </td>
                <td>
                  <xsl:value-of select="LastName" />
                </td>
                <td>
                  <xsl:value-of select="Country" />
                </td>
                <td>
                  <xsl:value-of select="BirthYear" />
                </td>
              </xsl:if>
            </xsl:if>
          </tr>
        </xsl:for-each>
      </table>
    </html>
  </xsl:template>
</xsl:stylesheet>

XSLT TXT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0" exclude-result-prefixes="msxsl">
  <xsl:output method="text" indent="yes" />
  <xsl:template match="/">
    <xsl:text>Raamatupoe raamatud</xsl:text>
    <xsl:for-each select="Bookstores/Bookstore/Book">
      <xsl:if test="@category='Crime'">
        <xsl:text />
        <xsl:value-of select="." />
      </xsl:if>
    </xsl:for-each>
    <xsl:text>---------------------------------</xsl:text>
    <xsl:for-each select="Bookstores/Bookstore">
      <xsl:if test="@country='Spain'">
        <xsl:text />
        <xsl:value-of select="." />
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

Output

XML output of given XML
XSLT XML output
XML output of given XML
XSLT XML output