SHOP

From ICO wiki
Revision as of 12:05, 17 March 2016 by Mbetlem (talk | contribs) (→‎Logi)
Jump to navigationJump to search

Meeskond

  • Johannes Tamm
  • Martin Mägi
  • Martin Betlem
  • Merilyn Renser

XML fail, stiilifail ja skeemifail

XML

<?xml version="1.0" encoding="utf-8" ?>
<Items>
  <Catalogs>
	<Catalog Name="Technology">
  	<Catalog Name="Memory"></Catalog>
  	<Catalog Name="Protsessor"></Catalog>
  	<Catalog Name="Storage">
    	<Catalog Name="Solid-state drive"></Catalog>
    	<Catalog Name="Hard disk drive"></Catalog>
  	</Catalog>
  	<Catalog Name="Computer"></Catalog>
  	<Catalog Name="Laptop"></Catalog>
	</Catalog>
    
	<Catalog Name="Furniture">
  	<Catalog Name="Chair"></Catalog>
  	<Catalog Name="Sofa"></Catalog>
  	<Catalog Name="Bed"></Catalog>
  	<Catalog Name="Table"></Catalog>
	</Catalog>
  </Catalogs>
 
  <Item Activated="true" Id="i1">
	<Name><![CDATA[Dell XPS 15]]></Name>
	<Catalog Name="Technology">
  	<Catalog Name="Laptop"></Catalog>
	</Catalog>
	<Price Currency="EUR"><![CDATA[100]]></Price>
	<Description><![CDATA[Intel i7 6500U 2.5 GHz (3852p) 16 GB, 512GB SSD Intel HD Graphics 520 (1326p) 13.3" 3200x1800]]></Description>
	<Images>
  	<Image><![CDATA[http://dri1.img.digitalrivercontent.net/Storefront/Company/msintl/images/English/en-INTL-Dell-XPS-15-i5-8gb-256gb-QF9-00100/en-INTL-L-Dell-XPS-15-i5-8gb-256gb-QF9-00100-mnco.jpg]]></Image>
  	<Image><![CDATA[http://scr.wfcdn.de/12791/Dell-XPS-15-2015-mit-Windows-10-1433327983-0-0.jpg]]></Image>
	</Images>
	<Availabilities>
  	<Availability  Quantity="5"><![CDATA[Akadeemia 5, Tallinn]]></Availability>
  	<Availability  Quantity="1"><![CDATA[Pikk 20, Tartu]]></Availability>
	</Availabilities>
	<Feedbacks>
  	<Feedback Rating="5"><![CDATA[Very good]]></Feedback>
  	<Feedback Rating="5"><![CDATA[I like it]]></Feedback>
	</Feedbacks>
  </Item>

  <Item Activated="true" Id="i2">
	<Name><![CDATA[4GB DDR2]]></Name>
	<Catalog Name="Technology">
  	<Catalog Name="Memory"></Catalog>
	</Catalog>
	<Price Currency="EUR"><![CDATA[100]]></Price>
	<Description><![CDATA[4GB DDR2 800Mhz CL6]]></Description>
	<Images>
  	<Image><![CDATA[http://76.my/Malaysia/4gb-kingston-desktop-pc-ddr2-ram-800mhz-pc-6400-kvr800d2n6-4g-amd-anonymous321-1410-25-Anonymous321@1.jpg]]></Image>
	</Images>
	<Availabilities>
  	<Availability  Quantity="10"><![CDATA[Akadeemia 5, Tallinn]]></Availability>
  	<Availability  Quantity="1"><![CDATA[Pikk 20, Tartu]]></Availability>
	</Availabilities>
	<Feedbacks>
  	<Feedback Rating="5"><![CDATA[Very good]]></Feedback>
  	<Feedback Rating="5"><![CDATA[I like it]]></Feedback>
	</Feedbacks>
  </Item>

  <Item Activated="true" Id="i3">
	<Name><![CDATA[HP DV600]]></Name>
	<Catalog Name="Technology">
  	<Catalog Name="Laptop"></Catalog>
	</Catalog>
	<Price Currency="EUR"><![CDATA[50]]></Price>
	<Description><![CDATA[CPU: T2080, RAM: 4GB, HDD 120GB, 15,3"]]></Description>
	<Images>
  	<Image><![CDATA[http://cnet2.cbsistatic.com/hub/i/r/2010/08/03/7ded434e-bb7a-11e2-8a8e-0291187978f3/thumbnail/770x433/3e631d8f8a16a3a9c6e69e0d98b652a9/32036702-2-440-overview-1.gif]]></Image>
  	<Image><![CDATA[http://i.ebayimg.com/00/s/NTI5WDcwMA==/z/Je8AAOSwcnpTrAD0/$_32.JPG]]></Image>
	</Images>
	<Availabilities>
  	<Availability  Quantity="5"><![CDATA[Akadeemia 5, Tallinn]]></Availability>
  	<Availability  Quantity="8"><![CDATA[Pikk 20, Tartu]]></Availability>
	</Availabilities>
	<Feedbacks>
  	<Feedback Rating="1"><![CDATA[It is not working well.]]></Feedback>
  	<Feedback Rating="3"><![CDATA[Videocard is problem]]></Feedback>
	</Feedbacks>
  </Item>
 
  <Item Activated="true" Id="i4">
	<Name><![CDATA[Oak chair]]></Name>
	<Catalog Name="Furniture">
  	<Catalog Name="Chair"></Catalog>
	</Catalog>
	<Price Currency="EUR"><![CDATA[75]]></Price>
	<Description><![CDATA[OAK 100%]]></Description>
	<Images>
  	<Image><![CDATA[http://curtainsandcomfort.com/furniture/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/w/e/westbury-reclaimed-oak-timber-dining-chairs---pair---wsr19.jpg]]></Image>
	</Images>
	<Availabilities>
  	<Availability  Quantity="8"><![CDATA[Pikk 20, Tartu]]></Availability>
	</Availabilities>
	<Feedbacks>
  	<Feedback Rating="5"><![CDATA[I like very]]></Feedback>
	</Feedbacks>
  </Item>

  <Item Activated="true" Id="i5">
	<Name><![CDATA[Oak big table]]></Name>
	<Catalog Name="Furniture">
  	<Catalog Name="Table"></Catalog>
	</Catalog>
	<Price Currency="EUR"><![CDATA[400]]></Price>
	<Description><![CDATA[NOW SALES!!!]]></Description>
	<Images>
  	<Image><![CDATA[http://iceinteriors.co.uk/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/c/l/clemence-richard-massive-dining-table_3.jpg]]></Image>
	</Images>
	<Availabilities>
  	<Availability  Quantity="131"><![CDATA[Punane 12, Tallinn]]></Availability>
	</Availabilities>
	<Feedbacks>
  	<Feedback Rating="5"><![CDATA[I like very]]></Feedback>
  	<Feedback Rating="5"><![CDATA[Cheapest!]]></Feedback>
  	<Feedback Rating="5"><![CDATA[I love it]]></Feedback>
  	<Feedback Rating="5"><![CDATA[Thanks!]]></Feedback>
	</Feedbacks>
  </Item>
</Items>

XSD

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" >
  <xs:complexType name="CatalogsType">
	<xs:choice minOccurs="0" maxOccurs="unbounded">
  	<xs:element name="Catalog" type="CatalogsType">
  	</xs:element>
	</xs:choice>
	<xs:attribute name="Name" type="xs:string" use="required" />
  </xs:complexType>
  <xs:complexType name="CatalogType">
	<xs:choice minOccurs="0" maxOccurs="1">
  	<xs:element name="Catalog" type="CatalogType">
  	</xs:element>
	</xs:choice>
	<xs:attribute name="Name" type="xs:string" use="required" />
  </xs:complexType>
  <xs:simpleType name="RatingType">
	<xs:restriction base="xs:integer">
  	<xs:minInclusive value="1"/>
  	<xs:maxInclusive value="5"/>
	</xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="PriceType">
	<xs:restriction base="xs:decimal">
  	<xs:minInclusive value="0"/>
	</xs:restriction>
  </xs:simpleType>
  <xs:element name="Items">
	<xs:complexType>
  	<xs:sequence>
    	<xs:element name="Catalogs">
      	<xs:complexType>
        	<xs:sequence>
          	<xs:element maxOccurs="unbounded" name="Catalog" type="CatalogsType" />
        	</xs:sequence>
      	</xs:complexType>
    	</xs:element>
    	<xs:element maxOccurs="unbounded" name="Item">
      	<xs:complexType>
        	<xs:sequence>
          	<xs:element name="Name" type="xs:string" />
          	<xs:element name="Catalog" type="CatalogType" />
          	<xs:element name="Price">
            	<xs:complexType>
              	<xs:simpleContent>
                	<xs:extension base="PriceType">
                  	<xs:attribute name="Currency" type="xs:string" use="required" />
                	</xs:extension>
              	</xs:simpleContent>
            	</xs:complexType>
          	</xs:element>
          	<xs:element name="Description" type="xs:string" />
          	<xs:element name="Images" minOccurs="0">
            	<xs:complexType>
              	<xs:sequence>
                	<xs:element maxOccurs="unbounded" name="Image" type="xs:string" />
              	</xs:sequence>
            	</xs:complexType>
          	</xs:element>
          	<xs:element name="Availabilities" minOccurs="0">
            	<xs:complexType>
              	<xs:sequence>
                	<xs:element maxOccurs="unbounded" name="Availability">
                  	<xs:complexType>
                    	<xs:simpleContent>
                      	<xs:extension base="xs:string">
                        	<xs:attribute name="Quantity" type="xs:unsignedInt" use="required" />
                      	</xs:extension>
                    	</xs:simpleContent>
                  	</xs:complexType>
                	</xs:element>
              	</xs:sequence>
            	</xs:complexType>
          	</xs:element>
          	<xs:element name="Feedbacks" minOccurs="0">
            	<xs:complexType>
              	<xs:sequence>
                	<xs:element maxOccurs="unbounded" name="Feedback">
                  	<xs:complexType>
                    	<xs:simpleContent>
                      	<xs:extension base="xs:string">
                        	<xs:attribute name="Rating" type="RatingType" use="required" />
                      	</xs:extension>
                    	</xs:simpleContent>
                  	</xs:complexType>
                	</xs:element>
              	</xs:sequence>
            	</xs:complexType>
          	</xs:element>
        	</xs:sequence>
        	<xs:attribute name="Activated" type="xs:boolean" use="required" />
        	<xs:attribute name="Id" type="xs:ID" use="required" />
      	</xs:complexType>
      	<xs:unique name="UniqueAddKey">
        	<xs:selector xpath="Item" />
        	<xs:field xpath="@Key" />
      	</xs:unique>
    	</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="@* | node()">
  	<html>
    	<head>
      	<title>Online shopping</title>
      	<style>
        	img {height: 150px;}
        	table>tbody>tr>td:first-child {vertical-align:top;}
        	table>tbody>tr:nth-child(odd) {background: #CCC}
        	table>thead {font-weight: bold;}
        	table table>tbody>tr>td:first-child{text-align: center;}
        	.free_space_height {height:50px;}
      	</style>
    	</head>
    	<body>
      	<h2>Catalog list</h2>
      	<ul>
        	<xsl:for-each select="/Items/Catalogs/Catalog">
          	<li>
            	<xsl:value-of select="@Name"/>
          	</li>
          	<xsl:if test="Catalog">
            	<ul>
              	<xsl:apply-templates select="Catalog" mode="list" />
            	</ul>
          	</xsl:if>
        	</xsl:for-each>
      	</ul>
      	<h2>All items</h2>
      	<xsl:for-each select="/Items/Item">
        	<xsl:apply-templates select="." />
      	</xsl:for-each>
     	 
      	<h2>Selected catalog (Furniture)</h2>
      	<xsl:for-each select="/Items/Item[Catalog/@Name='Furniture']">
        	<xsl:apply-templates select="." />
      	</xsl:for-each>
   	 
    	<h2>Selected item with id, whese name is i3</h2>
      	<xsl:for-each select="/Items/Item[@Id='i3']">
        	<xsl:apply-templates select="." />
      	</xsl:for-each>
    	</body>
  	</html>
	</xsl:template>
 
  <xsl:template match="Catalog" mode="list">
	<li>
    	<xsl:value-of select="@Name" />
	</li>
	<xsl:if test="Catalog">
  	<ul>
    	<xsl:apply-templates select="Catalog" mode="list" />
  	</ul>
	</xsl:if>
  </xsl:template>

  <xsl:template match="Item">
	<div class="free_space_height"></div>
	<table>
  	<tr>
    	<td>ID</td>
    	<td>
      	<xsl:value-of select="@Id"/>
    	</td>
  	</tr>
  	<tr>
    	<td>Name</td>
    	<td>
      	<xsl:value-of select="Name"/>
    	</td>
  	</tr>
  	<tr>
    	<td>Catalog</td>
    	<td>
      	<xsl:apply-templates select="Catalog" mode="short" />
    	</td>
  	</tr>
  	<tr>
    	<td>Price</td>
    	<td>
      	<xsl:choose>
        	<xsl:when test="Price=0">
          	<xsl:text>FREE</xsl:text>
        	</xsl:when>
        	<xsl:otherwise>
          	<xsl:value-of select="Price"/><xsl:text> </xsl:text><xsl:value-of select="Price/@Currency"/>
        	</xsl:otherwise>
      	</xsl:choose>
    	</td>
  	</tr>
  	<tr>
    	<td>Description</td>
    	<td>
      	<xsl:value-of select="Description"/>
    	</td>
  	</tr>
  	<xsl:if test="Images/Image">
    	<tr>
      	<td>Images</td>
      	<td>
          	<xsl:for-each select="Images/Image">
            	<img>
              	<xsl:attribute name="src">
              	<xsl:value-of select="."/>
              	</xsl:attribute>
            	</img>
          	</xsl:for-each>
      	</td>
    	</tr>
  	</xsl:if>
  	<tr>
    	<td>Availabilities</td>
    	<td>
      	<table>
        	<thead>
          	<tr>
            	<td>Quantity</td>
            	<td>Location</td>
          	</tr>
        	</thead>
        	<xsl:for-each select="Availabilities/Availability">
          	<tr>
            	<td>
              	<xsl:value-of select="@Quantity"/>
            	</td>
            	<td>
                	<xsl:value-of select="."/>
            	</td>
          	</tr>
        	</xsl:for-each>
      	</table>
    	</td>
  	</tr>
  	<xsl:if test="Feedbacks/Feedback">
    	<tr>
      	<td>Feedbacks</td>
      	<td>
        	<table>
          	<thead>
            	<tr>
              	<td>Rating</td>
              	<td>Comment</td>
            	</tr>
          	</thead>
          	<xsl:for-each select="Feedbacks/Feedback">
            	<tr>
              	<td>
                	<xsl:value-of select="@Rating"/>
              	</td>
              	<td>
                	<xsl:value-of select="."/>
              	</td>
            	</tr>
          	</xsl:for-each>
        	</table>
      	</td>
    	</tr>
  	</xsl:if>
	</table>
  </xsl:template>
 
  <xsl:template match="Catalog" mode="short">
	<xsl:value-of select="@Name" />
	<xsl:if test="Catalog">
    	<xsl:text>-></xsl:text>
    	<xsl:apply-templates select="Catalog" mode="short" />
	</xsl:if>
  </xsl:template>
</xsl:stylesheet>

Logi

15.veebruar

  • Meeskonna kokkupanek
  • Arutlemine
  • Plaanimine
  • XML loomine

16.märts

  • Wiki lehe loomine

17.märts

  • XML faili, stiilifaili ja skeemifaili esitamine