Meeskond: Falador
From ICO wiki
Meeskond: Falador
- Madis Lugus
- Taavi Metsvahi
- Kristjan Kivisild
XML/XSD/XSLT
XML
Vehicles that are being sold
<?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 unnesseseary fields and validated correct field types
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="vehicles">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="vehicle">
<xs:complexType>
<xs:sequence>
<xs:element name="type" type="xs:string" />
<xs:element name="make" type="xs:string" />
<xs:element minOccurs="0" name="model" type="xs:string" />
<xs:element minOccurs="0" name="specification" type="xs:string" />
<xs:element name="date" type="xs:string" />
<xs:element name="price">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:unsignedInt">
<xs:attribute name="currency" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="license-plate" type="xs:string" />
<xs:element name="location" type="xs:string" />
<xs:element minOccurs="0" name="description" type="xs:string" />
<xs:element minOccurs="0" name="technical-specs">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="seats" type="xs:unsignedInt" />
<xs:element minOccurs="0" name="doors" type="xs:unsignedInt" />
<xs:element minOccurs="0" name="engine">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="power">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:unsignedShort">
<xs:attribute name="unit" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="displacement">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="unit" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="type" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="mileage">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:unsignedInt">
<xs:attribute name="unit" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="fuel" type="xs:string" />
<xs:element minOccurs="0" name="transmission" type="xs:string" />
<xs:element minOccurs="0" name="color" type="xs:string" />
<xs:element minOccurs="0" name="weights">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="cross-weight">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:unsignedShort">
<xs:attribute name="unit" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="load-carring">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:unsignedShort">
<xs:attribute name="unit" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="equipment">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="item" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="images">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="image" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XSLT HTML
XSLT that returns HTML as output for every row in the xml with full data and pictures.
<?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>Müügis olevad autod</h1>
<hr />
<xsl:for-each select="vehicles/vehicle">
<table>
<tr>
<td>Tüüp</td>
<td>
<xsl:value-of select="type"/>
</td>
</tr>
<tr>
<td>Tootja</td>
<td>
<xsl:value-of select="make"/>
</td>
</tr>
<xsl:if test="model">
<tr>
<td>Mudel</td>
<td>
<xsl:value-of select="model"/> <xsl:value-of select="specification"/>
</td>
</tr>
</xsl:if>
<xsl:if test="date">
<tr>
<td>Esmane registreerimine</td>
<td>
<xsl:value-of select="date"/>
</td>
</tr>
</xsl:if>
<xsl:if test="price">
<tr>
<td>Hind</td>
<td>
<xsl:value-of select="price"/> <xsl:value-of select="@currency"/>
</td>
</tr>
</xsl:if>
<xsl:if test="license-plate">
<tr>
<td>Reg. number</td>
<td>
<xsl:value-of select="license-plate"/>
</td>
</tr>
</xsl:if>
<xsl:if test="location">
<tr>
<td>Asukoht</td>
<td>
<xsl:value-of select="location"/>
</td>
</tr>
</xsl:if>
<xsl:if test="description">
<tr>
<td>Kirjeldus</td>
<td>
<xsl:value-of select="description"/>
</td>
</tr>
</xsl:if>
<xsl:if test="technical-specs">
<th>
<td colspan="100%">Tehnilised andmed</td>
</th>
<xsl:if test="technical-specs/seats">
<tr>
<td>Istekohti</td>
<td>
<xsl:value-of select="technical-specs/seats"/>
</td>
</tr>
</xsl:if>
<xsl:if test="technical-specs/doors">
<tr>
<td>Uksi</td>
<td>
<xsl:value-of select="technical-specs/doors"/>
</td>
</tr>
</xsl:if>
<xsl:if test="technical-specs/engine">
<xsl:if test="technical-specs/engine/power">
<tr>
<td>Võimsus</td>
<td>
<xsl:value-of select="technical-specs/engine/power"/> <xsl:value-of select="technical-specs/engine/power/@unit"/>
</td>
</tr>
</xsl:if>
<xsl:if test="technical-specs/engine/displacement">
<tr>
<td>Mootori maht</td>
<td>
<xsl:value-of select="technical-specs/engine/displacement"/> <xsl:value-of select="technical-specs/engine/displacement/@unit"/>
</td>
</tr>
</xsl:if>
<xsl:if test="technical-specs/engine/displacement">
<tr>
<td>Mootori tüüp</td>
<td>
<xsl:value-of select="technical-specs/engine/type"/>
</td>
</tr>
</xsl:if>
</xsl:if>
<xsl:if test="technical-specs/mileage">
<tr>
<td>Läbisõit</td>
<td>
<xsl:value-of select="technical-specs/mileage"/> <xsl:value-of select="technical-specs/mileage/@unit"/>
</td>
</tr>
</xsl:if>
<xsl:if test="technical-specs/fuel">
<tr>
<td>Kütuse tüüp</td>
<td>
<xsl:value-of select="technical-specs/fuel"/>
</td>
</tr>
</xsl:if>
<xsl:if test="technical-specs/transmission">
<tr>
<td>Käigukast</td>
<td>
<xsl:value-of select="technical-specs/transmission"/>
</td>
</tr>
</xsl:if>
<xsl:if test="technical-specs/color">
<tr>
<td>Värv</td>
<td>
<xsl:value-of select="technical-specs/color"/>
</td>
</tr>
</xsl:if>
</xsl:if>
<xsl:if test="equipment">
<th>
<td colspan="100%">Varustus</td>
</th>
<xsl:for-each select="equipment/item">
<tr>
<td colspan="100%">
<xsl:value-of select="./text()"/>
</td>
</tr>
</xsl:for-each>
</xsl:if>
<xsl:if test="images">
<tr>
<td colspan="100%">
<xsl:for-each select="images/image">
<img>
<xsl:attribute name="src">
<xsl:value-of select="./text()"/>
</xsl:attribute>
</img>
</xsl:for-each>
</td>
</tr>
</xsl:if>
</table>
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT XML
XSLT that returns XML as output. It shows adverticements only over 20 000 € price point.
<?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="/">
<products>
<xsl:for-each select="vehicles/vehicle">
<xsl:if test="price>=20000">
<product>
<make>
<xsl:value-of select="make"/>
</make>
<model>
<xsl:value-of select="model"/>
</model>
<price>
<xsl:value-of select="price"/>
</price>
<description>
<xsl:value-of select="description"/>
</description>
<xsl:if test="technical-specs/engine/power">
<power>
<xsl:value-of select="technical-specs/engine/power"/>
</power>
</xsl:if>
</product>
</xsl:if>
</xsl:for-each>
</products>
</xsl:template>
</xsl:stylesheet>