Meeskond: Falador

From ICO wiki
Revision as of 22:03, 20 March 2017 by Mlugus (talk | contribs) (Created page with "== Meeskond: Falador == * Madis Lugus * Taavi Metsvahi * Kristjan Kivisild ==XML/XSD/XSLT== ===XML=== Plants with names, needed light conditions etc. <div class="toccolour...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Meeskond: Falador

  • Madis Lugus
  • Taavi Metsvahi
  • Kristjan Kivisild


XML/XSD/XSLT

XML

Plants with names, needed light conditions etc.

<?xml version="1.0" encoding="utf-8"?>
<vehicles>
  <vehicle id="1">
    <type><![CDATA[Bus]]></type>
    <make><![CDATA[Mercedes-Benz]]></make>
    <model><![CDATA[Sprinter]]></model>
    <date>05/2003</date>
    <price currency="EUR">5500</price>
    <license-plate><![CDATA[ABS 550]]></license-plate>
    <location><![CDATA[Estonia, Tallinn, Raja 4C]]></location>
    <description><![CDATA[Selling a big white van, it can haul ass with alot of people in it, making it ideal for transporting immigrants across the border]]></description>
    <technical-specs>
      <seats>5</seats>
      <doors>4</doors>
      <engine>
        <power unit="kW">95</power>
        <displacement unit="L">2.2</displacement>
        <type><![CDATA[R6]]></type>
      </engine>
      <mileage unit="KM">75600</mileage>
      <fuel><![CDATA[Diesel]]></fuel>
      <transmission><![CDATA[Automatic]]></transmission>
      <color><![CDATA[white]]></color>
      <weights>
        <cross-weight unit="kg">4000</cross-weight>
        <load-carring unit="kg">1760</load-carring>
      </weights>
    </technical-specs>
    <equipment>
      <item><![CDATA[ABS]]></item>
      <item><![CDATA[Traction control]]></item>
      <item><![CDATA[Sunroof]]></item>
      <item><![CDATA[Tow hitch]]></item>
    </equipment>
    <images>
      <image><![CDATA[https://static.cargurus.com/images/site/2008/04/30/19/51/2003_mercedes-benz_sprinter-pic-65605-1600x1200.jpeg]]></image>
      <image><![CDATA[https://i.ytimg.com/vi/sDv15TPLvvo/maxresdefault.jpg]]></image>
    </images>
  </vehicle>
  <vehicle id="2">
    <type><![CDATA[Passenger car]]></type>
    <make><![CDATA[Audi]]></make>
    <model><![CDATA[S5]]></model>
    <specification><![CDATA[Sportback Quattro TFSI]]></specification>
    <date>02/2012</date>
    <price currency="EUR">26900</price>
    <license-plate><![CDATA[WAU ZZZ]]></license-plate>
    <location><![CDATA[Estonia, Tallinn, Raja 4C]]></location>
    <description><![CDATA[Stolen from: Germany]]></description>
    <technical-specs>
      <seats>5</seats>
      <doors>5</doors>
      <engine>
        <power unit="kW">245</power>
        <displacement unit="L">3.0</displacement>
        <type><![CDATA[V6]]></type>
      </engine>
      <mileage unit="KM">169000</mileage>
      <fuel><![CDATA[Petrol]]></fuel>
      <transmission><![CDATA[Automatic (Tiptronic)]]></transmission>
      <color><![CDATA[Dark brown metal]]></color>
      <weights>
        <cross-weight unit="kg">1820</cross-weight>
      </weights>
    </technical-specs>
    <equipment>
      <item><![CDATA[ABS]]></item>
      <item><![CDATA[Traction control]]></item>
      <item><![CDATA[Sunroof]]></item>
      <item><![CDATA[Electric handbrake]]></item>
      <item><![CDATA[Central locking]]></item> 
      <item><![CDATA[Bang & Olufsen sound system]]></item>
      <item><![CDATA[Xenon headlight]]></item>
      <item><![CDATA[Adaptive lights]]></item>
    </equipment>
    <images>
      <image><![CDATA[http://img6.auto24.ee/auto24/320/863/84913863.jpg]]></image>
      <image><![CDATA[http://img5.auto24.ee/auto24/320/872/84913872.jpg]]></image>
      <image><![CDATA[http://img5.auto24.ee/auto24/320/876/84913876.jpg]]></image>
    </images>
  </vehicle>
  <vehicle id="40000">
    <type><![CDATA[Mototechnics]]></type>
    <make><![CDATA[BMW]]></make>
    <model><![CDATA[S1000RR]]></model>
    <date>04/2010</date>
    <price currency="EUR">8000</price>
    <license-plate><![CDATA[WB 50]]></license-plate>
    <location><![CDATA[Estonia, Tallinn, Raja 4C]]></location>
    <description><![CDATA[ABS ja veojõukontroll. 
Lisadeks: Paagi kaitse kleebis ja stomgrip. 
Tehniliselt heas korras !]]></description>
    <technical-specs>
      <seats>2</seats>
      <engine>
        <power unit="kW">142</power>
        <displacement unit="cm3">999</displacement>
        <type><![CDATA[R4]]></type>
      </engine>
      <mileage unit="KM">13467</mileage>
      <fuel><![CDATA[Petrol]]></fuel>
      <transmission><![CDATA[Manual]]></transmission>
      <color><![CDATA[White]]></color>
    </technical-specs>
    <equipment>
      <item><![CDATA[ABS]]></item>
      <item><![CDATA[Traction control]]></item>
      <item><![CDATA[DTC]]></item>
    </equipment>
    <images>
      <image><![CDATA[http://img6.auto24.ee/auto24/320/780/87505780.jpg]]></image>
      <image><![CDATA[http://img7.auto24.ee/auto24/320/785/87505785.jpg]]></image>
    </images>
  </vehicle>
  <vehicle id="400001">
    <type><![CDATA[passenger car]]></type>
    <make><![CDATA[Tesla]]></make>
    <model><![CDATA[Model S 85D]]></model>
    <date>06/2015</date>
    <price currency="EUR">97340</price>
    <location><![CDATA[Estonia, Tallinn, Raja 4C]]></location>
    <description><![CDATA[Selling a car, that is ment for people who want to brag about saving the planet, but actually sell their farely new car to buy this one, making them acctually more harmful to the planet]]></description>
    <technical-specs>
      <seats>5</seats>
      <doors>4</doors>
      <engine>
        <power unit="kW">310</power>
      </engine>
      <mileage unit="KM">45000</mileage>
      <fuel><![CDATA[Electric]]></fuel>
      <transmission><![CDATA[Automatic]]></transmission>
      <color><![CDATA[dark gray met.]]></color>
    </technical-specs>
    <equipment>
      <item><![CDATA[Parking camera]]></item>
      <item><![CDATA[Parking aid]]></item>
      <item><![CDATA[Lane assist]]></item>
      <item><![CDATA[Airbars]]></item>
      <item><![CDATA[Alloy wheels]]></item>
      <item><![CDATA[Power steering]]></item>
      <item><![CDATA[ABS]]></item>
      <item><![CDATA[Traction control]]></item>
      <item><![CDATA[Sunroof]]></item>
      <item><![CDATA[Tow hitch]]></item>
    </equipment>
    <images>
      <image><![CDATA[https://s1.cdn.autoevolution.com/images/news/tesla-model-s-85d-range-to-increase-with-new-software-coming-in-january-90666-7.jpg]]></image>
      <image><![CDATA[http://www.themotorreport.com.au/content/image/2/0/2015_tesla_model_s_p85d_05-0224-920x544.jpg]]></image>
    </images>
  </vehicle>
</vehicles>


XSD

Assigned minOccurs to PLANT and DIM2, changed attribute SpiritAnimal's use to optional and Plants attribute Id to unsignedInt

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="CATALOG">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="unbounded" name="DIM2">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="1" maxOccurs="unbounded" name="PLANT">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="COMMON" type="xs:string" />
                    <xs:element name="BOTANICAL" type="xs:string" />
                    <xs:element name="ZONE" type="xs:string" />
                    <xs:element name="LIGHT" type="xs:string" />
                    <xs:element name="PRICE" type="xs:string" />
                    <xs:element name="AVAILABILITY" type="xs:unsignedInt" />
                  </xs:sequence>
                  <xs:attribute name="SpiritAnimal" type="xs:string" use="optional" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="Id" type="xs:unsignedInt" use="required" />
            <xs:attribute name="Name" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="Id" type="xs:unsignedInt" use="required" />
      <xs:attribute name="Name" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>
</xs:schema>


XSLT HTML

XSLT that returns HTML as output. It creates a table that consists of plants common name, necessary light condition and price. Assigned light conditon necessity is color coded by availability value fulfilling certaing condition.

<?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>
        <h1>My plants</h1>
        <h4>Color coded by value of availability fitting in range</h4>
        <table>
          <tr>
            <td width="300px">
              <b>Common name</b>
            </td>
            <td width="100px" bgcolor="yellow">
              <b>Light contitions</b>
            </td>
            <td width="70px">
              <b>Dollar tokens</b>
            </td>
          </tr>
          <xsl:for-each select="/CATALOG/DIM2/PLANT">
            <tr>
              <td width="300px">
                <xsl:value-of select="COMMON"/>
              </td>

              <xsl:choose>
                <xsl:when test="./AVAILABILITY &lt; 020000">
                  <td width="150px" bgcolor="orange">
                    <xsl:value-of select="LIGHT"/>
                  </td>
                </xsl:when>
                <xsl:when test="./AVAILABILITY &lt; 030000">
                  <td width="150px" bgcolor="green">
                    <xsl:value-of select="LIGHT"/>
                  </td>
                </xsl:when>
                <xsl:when test="./AVAILABILITY &lt; 050000">
                  <td width="150px" bgcolor="blue">
                    <xsl:value-of select="LIGHT"/>
                  </td>
                </xsl:when>
                <xsl:otherwise>
                  <td width="150px">
                    <xsl:value-of select="LIGHT"/>
                  </td>
                </xsl:otherwise>
              </xsl:choose>

              <td width="70px">
                <xsl:value-of select="PRICE"/>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>


XSLT XML

XSLT that returns XML as output. It sorts plants inside each DIM2 separately and lists only the ones with availability value below 050000.

<?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="/">
    <html>
      <body>
        <h1>Plants sorted by availability in separate XML dimensions. Only entries with availability below 050000 are shown.</h1>
        <xsl:for-each select="/CATALOG/DIM2">
          <h3>
            <xsl:value-of select="@Name"/>
          </h3>
          <ol>
            <xsl:for-each select="PLANT">
              <xsl:sort select="AVAILABILITY"/>
              <xsl:for-each select=".">
                <xsl:variable name="av" select="050000"/>
                <xsl:if test="./AVAILABILITY &lt; $av">
                  <li>
                    <b>
                      <xsl:value-of select="BOTANICAL"/>
                    </b><br/>
                    Availability: <xsl:value-of select="AVAILABILITY"/><br/>
                    Zone: <xsl:value-of select="ZONE"/>
                  </li>
                </xsl:if>
              </xsl:for-each>
            </xsl:for-each>
          </ol>
        </xsl:for-each>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>


Output

Pictures of outputs created by XSLT-s listed above.

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

Veebiteenus

Analüüs

Teenus

Klientrakendused

Retsensioonid

XML-failid

Veebiteenus

Klientrakendus