Tiim Placeholder
From ICO wiki
Tiim Placeholder
Koosseis
- Eero Jämsä
- ..
- ..
XML Fail
<?xml version="1.0" encoding="utf-8" ?> <cars> <car seeria="S"> <name>VOLVO S60</name> <accessories> <accessory group="styling" type="wheels"><![CDATA[ Aluminum rim "Balder" 7 x 17"]]></accessory> <accessory group="tech_and_sound" type="audio"><![CDATA[Digital radio, DAB/DAB+ ((Excl. BR))]]></accessory> <accessory group="comfort" type="seats"><![CDATA[Pillow, comfort]]></accessory> </accessories> </car> <car seeria="S"> <name>VOLVO S80</name> <accessories> <accessory group="maintenance" type="interior"><![CDATA[ Leather care]]></accessory> <accessory group="comfort" type="climate"><![CDATA[Sunshade, rear doors]]></accessory> <accessory group="tech_and_sound" type="audio"><![CDATA[USB and iPod® Music Interface, cradle]]></accessory> <accessory group="styling" type="wheels"><![CDATA[Aluminum rim "Magni" 8 x 18"]]></accessory> </accessories> </car> <car seeria="V"> <name>VOLVO V40</name> <accessories> <accessory group="comfort" type="storage"><![CDATA[Glasses holder]]></accessory> <accessory group="tech_and_sound" type="audio"><![CDATA[Digital radio, DAB/DAB+ ((Excl. BR))]]></accessory> </accessories> </car> <car seeria="XC"> <name>VOLVO XC60</name> <accessories> <accessory group="comfort" type="seats"><![CDATA[ Rear seat guard]]></accessory> <accessory group="comfort" type="climate"><![CDATA[Remote start, fuel-driven heater (Excl. GB, BR)]]></accessory> <accessory group="tech_and_sound" type="audio"><![CDATA[CD-changer, 6-disc]]></accessory> <accessory group="styling" type="wheels"><![CDATA[Aluminum rim "Cratus" 8 x 20"]]></accessory> <accessory group="styling" type="interior_styling"><![CDATA[Steering wheel, leather]]></accessory> <accessory group="performance" type="software"><![CDATA[Polestar Performance Software (Excl. BE, BR, FR, IT, LU, NO)]]></accessory> </accessories> </car> <car seeria="C"> <name>VOLVO C70</name> <accessories> <accessory group="styling" type="wheels"><![CDATA[ Aluminum rim "Castula" 7.5 x 16"]]></accessory> <accessory group="tech_and_sound" type="communication"><![CDATA[Handsfree, Bluetooth]]></accessory> <accessory group="comfort" type="climate"><![CDATA[Windblocker]]></accessory> </accessories> </car> <car seeria="V"> <name>VOLVO V60</name> <accessories> <accessory group="maintenance" type="exterior"><![CDATA[ Dirt and water repellent, side window (Excl. SY)]]></accessory> <accessory group="comfort" type="storage"><![CDATA[Cup holder]]></accessory> <accessory group="tech_and_sound" type="audio"><![CDATA[Infotainment levels upgrade]]></accessory> <accessory group="styling" type="wheels"><![CDATA[Aluminum rim "Magni" 8 x 18"]]></accessory> <accessory group="styling" type="wheels"><![CDATA[ Aluminum rim "Castula" 7.5 x 16"]]></accessory> </accessories> </car> <car seeria="S"> <name>VOLVO S80</name> <accessories> <accessory group="tech_and_sound" type="audio"><![CDATA[CD-changer, 6-disc]]></accessory> <accessory group="tech_and_sound" type="audio"><![CDATA[Digital radio, DAB/DAB+ ((Excl. BR))]]></accessory> <accessory group="tech_and_sound" type="audio"><![CDATA[Infotainment levels upgrade]]></accessory> </accessories> </car> <car seeria="XC"> <name>VOLVO XC90</name> <accessories> <accessory group="comfort" type="seats"><![CDATA[ Rear seat guard]]></accessory> <accessory group="comfort" type="climate"><![CDATA[Electric engine heater (Excl. GB)]]></accessory> <accessory group="tech_and_sound" type="audio"><![CDATA[CD-changer, 6-disc]]></accessory> <accessory group="styling" type="wheels"><![CDATA[Aluminum rim "Cratus" 8 x 20"]]></accessory> <accessory group="styling" type="exterior_styling"><![CDATA[Accessory, R-design, general description]]></accessory> <accessory group="performance" type="software"><![CDATA[Polestar Performance Software (Excl. BE, BR, FR, IT, LU, NO)]]></accessory> </accessories> </car> </cars>
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="cars"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="car"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string" /> <xs:element name="accessories"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="accessory"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="group" type="xs:string" use="required" /> <xs:attribute name="type" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="seeria" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
XSLT
Esimene
Kuva välja kõikide isendite lisavarustus
<?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="/"> <xsl:for-each select="cars/car"> <h3> <xsl:value-of select="name"/> </h3> <ul> <xsl:for-each select="accessories/accessory"> <li> <xsl:value-of select="."/> </li> </xsl:for-each> </ul> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Teine
Kuvame kõik volvod, kellel on lisavarustuses veljed
<?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="/"> <xsl:for-each select="cars/car"> <xsl:if test="contains(accessories[accessory], 'rim')"> <xsl:value-of select="name"/> <br /> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Kolmas
Kuva kõik lisavarustuse grupid ning nende all olevad tüübid
<?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:key name="groups" match="/cars/car/accessories/accessory" use="@group" /> <xsl:key name="types" match="/cars/car/accessories/accessory" use="@type"/> <xsl:template match="/"> <ul> <xsl:for-each select="cars/car/accessories/accessory [generate-id(@group) = generate-id(key('groups', @group)[1]/@group)]"> <li> <xsl:value-of select="@group"/> <xsl:variable name="group" select="@group"/> <ul> <xsl:for-each select="/cars/car/accessories/accessory [@group = $group][generate-id(@type) = generate-id(key('types', @type)[1]/@type)]"> <li> <xsl:value-of select="@type"/> </li> </xsl:for-each> </ul> </li> </xsl:for-each> </ul> </xsl:template> </xsl:stylesheet>