TTiim

From ICO wiki
Jump to navigationJump to search

Tiimi liikmed

  • Eero Jämsä
  • ...
  • ...

Hakkasin natuke hilja asjaga tegelema. Et mitte niisama kuhugi tiimi trügida oma panust andmata, siis tegin hoopis oma tiimi. Kes tahaks liituda, siis andke teada ejamsa@itcollege.ee

XML

XML failis hoitakse raamatukogus laenutatavate raamatute infot. Siinkohal ei ole tähtis, kes laenutas ja millal tagasta(s/b), vaid milliseid raamatuid on võimalik laenutada.

XML

<?xml version="1.0" encoding="UTF-8"?>
<library>	
	<categories>
		<category id="1">Arts and Architecture</category>
		<category id="2">Law</category>
		<category id="3">Language</category>
		<category id="4">Fiction & related items</category>
		<category id="5">Computing & information technology</category>		
	</categories>
	
	<book_formats>
		<book_format id="1">Paperback</book_format>
		<book_format id="2">E-book</book_format>
	</book_formats>
	
	<books>
		<book id="1" is_available="false" book_format_id="1" category_id="4">
			<title>Chronicles of Narnia New edition</title>
			<authors>
				<author>C. S. Lewis</author>
			</authors>
			<description>"The Narnia Chronicles", first published in 1950, have been and remain some of the most enduringly popular books ever published. The best known, "The Lion, the Witch and the Wardrobe", has been translated into 29 languages!</description>
			<isbn10>0006753949</isbn10>
		</book>
		
		<book id="1" is_available="true" book_format_id="1" category_id="5">
			<title>Programming Perl 4th Revised edition</title>
			<authors>
				<author>Tom Christiansen</author>
				<author>brian d. foy</author>
				<author>Larry Wall</author>
				<author>Jon Orwant</author>
			</authors>
			<description>When it comes to learning Perl, programmers consider this book...</description>
			<isbn10>0596004923</isbn10>
		</book>
		
		<book id="1" is_available="false" book_format_id="1" category_id="5">
			<title>Shadow Algorithms Data Miner</title>
			<authors>
				<author>Andrew Woo</author>
				<author>Pierre Poulin</author>
			</authors>
			<description>Digital shadow generation continues to be an important aspect of visualization and visual effects in film, games, simulations, and scientific applications.</description>
			<isbn10>1439880239</isbn10>
		</book>
		
		<book id="1" is_available="true" book_format_id="1" category_id="3">
			<title>Teach Yourself Complete Estonian</title>
			<authors>
				<author>Mare Kitsnik</author>
				<author>Leelo Kingisepp</author>
			</authors>
			<description>The complete course for a fun and effective way to learn Estonian.</description>
			<isbn10>1444106902</isbn10>
		</book>
	</books>
</library>

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="library">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="categories">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" 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:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="book_formats">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="book_format">
                <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:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="books">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="book">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="title" type="xs:string" />
                    <xs:element name="authors">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="author" type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="description" type="xs:string" />
                    <xs:element name="isbn10" type="xs:unsignedInt" />
                  </xs:sequence>
                  <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                  <xs:attribute name="is_available" type="xs:boolean" use="required" />
                  <xs:attribute name="book_format_id" type="xs:unsignedByte" use="required" />
                  <xs:attribute name="category_id" type="xs:unsignedByte" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT

Allolev kood kuvab kõik raamatud, mis on seotud infotehnoloogiaga ja seetõttu ka it osakond tahaks kindlasti laenutada

<?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="@* | node()">
      <html>
        <body>
          <h2>Raamatud IT osakonnale</h2>
          <table border="1">
            <tr bgcolor="#9acd32">
              <th>Pealkiri</th>
              <th>Kirjeldus</th>
              <th>Autorid</th>
            </tr>
            <xsl:for-each select="books/book">
              <xsl:if test="@category_id = 5">
                <tr>
                  <td>
                    <xsl:value-of select="title"/>
                  </td>
                  <td>
                    <xsl:value-of select="description"/>
                  </td>
                  <td>
                    <ul>
                      <xsl:for-each select="authors/author">
                        <li>
                          <xsl:value-of select="."/>
                        </li>
                      </xsl:for-each>
                    </ul>
                  </td>
                </tr>
              </xsl:if>
            </xsl:for-each>
          </table>
        </body>
      </html>
    </xsl:template>
</xsl:stylesheet>