Alt + Tab

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

Meeskond Alt + Tab Võrgurakendused II

  • Mihkel Roots
  • Roland Soosaar
  • Krista Norak

Esimene Osa

XML

  <?xml version="1.0" encoding="utf-8" ?>
  <?xml-stylesheet type="text/xsl" href="Echo-html.xslt"?>
  <Carshop>
    <Shop>
      <Name>United Motors</Name>
      <Address>
        <Country>Estonia</Country>
        <City>Tallinn</City>
        <MobileNumber>7777777</MobileNumber>
      </Address>
    </Shop>
    <Cars>
      
      <Car type="saloon">
        <CarMake Name="BMW">
          <CarModel ModelName="X1" Year="2011">
            <Mileage>1000</Mileage>
            <Price>
              <Amount>20000</Amount>
              <Currency>EUR</Currency>
            </Price>
            <Image><![CDATA[http://bmw.co.uk/dam/brandBM/common/newvehicles/x-series/x1/2015/flash/f48_x1_highlights_assets/lines_slider/img/digital/sport-line-front.jpg]]></Image>
          </CarModel>
        </CarMake>
      </Car>
      
      <Car type="SUV">
        <CarMake Name="BMW">
          <CarModel ModelName="X5" Year="2010">
            <Mileage>500</Mileage>
            <Price>
              <Amount>25000</Amount>
              <Currency>EUR</Currency>
            </Price>
            <Image><![CDATA[http://www.bmw.com.au/content/dam/bmw/common/all-models/x-series/x5/2015/at-a-glance/x5_at-a-glance_stagepresentation.jpg/jcr:content/renditions/cq5dam.resized.img.1680.large.time1448008829330.jpg]]></Image>
          </CarModel>
        </CarMake>
      </Car>
      
      <Car type="saloon">
        <CarMake Name="BMW">
          <CarModel ModelName="X3" Year="2012">
            <Mileage>700</Mileage>
            <Price>
              <Amount>15000</Amount>
              <Currency>EUR</Currency>
            </Price>
            <Image><![CDATA[http://s3.caradvice.com.au/thumb/1000/562/wp-content/uploads/2014/08/2015-BMW-X3-36.jpg]]></Image>
          </CarModel>
        </CarMake>
      </Car>
      
      <Car type="SUV">
        <CarMake Name="BMW">
          <CarModel ModelName="X6" Year="2009">
            <Mileage>800</Mileage>
            <Price>
              <Amount>23000</Amount>
              <Currency>EUR</Currency>
            </Price>
            <Image><![CDATA[https://i.ytimg.com/vi/a6hjQDtYSnM/maxresdefault.jpg]]></Image>
          </CarModel>
        </CarMake>
      </Car>
      
    </Cars>
  </Carshop>

XSD

  <?xml version="1.0" encoding="utf-8"?>
  <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Carshop">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="Shop">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="Name" type="xs:string" />
                <xs:element name="Address">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element name="Country" type="xs:string" />
                      <xs:element name="City" type="xs:string" />
                      <xs:element name="MobileNumber" type="xs:unsignedInt" />
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element name="Cars">
            <xs:complexType>
              <xs:sequence>
                <xs:element maxOccurs="unbounded" name="Car">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element name="CarMake">
                        <xs:complexType>
                          <xs:sequence>
                            <xs:element name="CarModel">
                              <xs:complexType>
                                <xs:sequence>
                                  <xs:element name="Mileage" type="xs:unsignedShort" />
                                  <xs:element name="Price">
                                    <xs:complexType>
                                      <xs:sequence>
                                        <xs:element name="Amount" type="xs:unsignedShort" />
                                        <xs:element name="Currency" type="xs:string" />
                                      </xs:sequence>
                                    </xs:complexType>
                                  </xs:element>
                                  <xs:element name="Image" type="xs:string" />
                                </xs:sequence>
                                <xs:attribute name="ModelName" type="xs:string" use="required" />
                                <xs:attribute name="Year" type="xs:unsignedShort" use="required" />
                              </xs:complexType>
                            </xs:element>
                          </xs:sequence>
                          <xs:attribute name="Name" type="xs:string" use="required" />
                        </xs:complexType>
                      </xs:element>
                    </xs:sequence>
                    <xs:attribute name="type" type="xs:string" use="required" />
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </xs:schema>

XSLT HTML

  <?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>
          <head>
            <title>Autopood</title>
          </head>
          <body>
            <xsl:variable name="Shop" select="/Carshop/Shop"/>
            <xsl:variable name="ShopName" select="$Shop/Name"/>
            <xsl:variable name="Country" select="$Shop/Address/Country"/>
            <xsl:variable name="City" select="$Shop/Address/City"/>
            <xsl:variable name="MobileNumber" select="$Shop/Address/MobileNumber"/>
            <xsl:variable name="ShopAddress" select="concat($Country,', ',$City,', ', $MobileNumber)"/>

            <h1>
              <xsl:value-of select="$ShopName"/>    
            </h1>
            <h4>
              <xsl:value-of select="$ShopAddress"/>
            </h4>

            <ul>
              <xsl:for-each select="Carshop/Cars/Car"> 
                <li>
                  <h4>
                    <xsl:value-of select="concat(CarMake/@Name, ' ', CarMake/CarModel/@ModelName)"/>
                  </h4>
                  <div>
                    <xsl:variable name="CarModelPath" select="CarMake/CarModel"/>
                    
                    Release year:
                    <xsl:value-of select="$CarModelPath/@Year"/>
                    <br/>
                    Body type:
                    <xsl:value-of select="@type"/>
                    <br/>
                    Mileage:
                    <xsl:value-of select="$CarModelPath/Mileage"/>
                    <br/>
                    Price:
                    <xsl:value-of select="concat($CarModelPath/Price/Amount, ' ', $CarModelPath/Price/Currency)"/>
                    <p>
                      <xsl:variable name="ImageUrl" select="$CarModelPath/Image"/>
                      <img src="{$ImageUrl}" style="width: 500px;"/>
                    </p>                        
                  </div>          
                </li>
              </xsl:for-each>
            </ul>
            
          </body>
        </html>
      </xsl:template>
  </xsl:stylesheet>

XSLT XML

  <?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="xml" indent="yes"/>

      <xsl:template match="/">
        <Carshop>
          <CarType>
            <xsl:for-each select="Carshop/Cars">
              <xsl:variable name="Counter" select="count(Car/CarMake/@Name)"/>
              <Type amount="{$Counter}">
                <xsl:value-of select="Car/CarMake/@Name"/>
              </Type>
            </xsl:for-each>
          </CarType>
          <xsl:for-each select="Carshop/Cars/Car">
            <Cars>

              <xsl:variable name="CarName" select="CarMake/@Name"/>
              <xsl:variable name="CarModelName" select="CarMake/CarModel/@ModelName"/>
              <xsl:variable name="CarModelPath" select="CarMake/CarModel"/>
              <xsl:variable name="Currency" select="$CarModelPath/Price/Currency"/>

              <Name CarName="{$CarName}">
                <xsl:value-of select="$CarModelName"/>
              </Name>
              <ReleaseYear>
                <xsl:value-of select="$CarModelPath/@Year"/>
              </ReleaseYear>
              <Mileage>
                <xsl:value-of select="$CarModelPath/Mileage"/>
              </Mileage>
              <CarBodyType>
                <xsl:value-of select="@type"/>
              </CarBodyType>
              <Price Currency="{$Currency}">
                <xsl:value-of select="$CarModelPath/Price/Amount"/>
              </Price>
              <Image>
                <xsl:value-of select="$CarModelPath/Image"/>
              </Image>  
            </Cars>
          </xsl:for-each>
        </Carshop>
      </xsl:template>
  </xsl:stylesheet>