Hops
From ICO wiki
Meeskond
- Liikmed:
- Artur Hokkonen
- Margus Parts
- Hanno Sirkel
- Lauri Õunmaa
Idee
Luua 4-tasemeline XML definitsioon, näidis sellele ning transleerimised HTML ja XML formaati.
XML
XML fail
<?xml version="1.0" encoding="UTF-8"?>
<tns:autod xmlns:tns="http://www.example.org/autod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/autod autod.xsd ">
<tns:auto id="0" mark="Ford" mudel="Sierra">
<tns:mootor>
<tns:kytus>bensiin</tns:kytus>
<tns:kubatuur yhik="ccm">2000</tns:kubatuur>
</tns:mootor>
<tns:kere v2rv="punane"/>
</tns:auto>
<tns:auto id="1" mark="ZAZ" mudel="969">
<tns:mootor>
<tns:kytus>diisel</tns:kytus>
<tns:kubatuur yhik="ccm">2500</tns:kubatuur>
</tns:mootor>
<tns:kere v2rv="roheline"/>
</tns:auto>
<tns:auto id="2" mark="Saab" mudel="9-5">
<tns:mootor>
<tns:kytus>bensiin</tns:kytus>
<tns:kubatuur yhik="ccm">1500</tns:kubatuur>
</tns:mootor>
<tns:kere v2rv="sinine"/>
</tns:auto>
<tns:auto id="3" mark="Volvo" mudel="960">
<tns:mootor>
<tns:kytus>elekter</tns:kytus>
</tns:mootor>
<tns:kere v2rv="sinine"/>
</tns:auto>
</tns:autod>
XSD fail
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/autod"
xmlns:tns="http://www.example.org/autod"
elementFormDefault="qualified">
<simpleType name="kytusSimpleType">
<restriction base="string">
<enumeration value="bensiin"></enumeration>
<enumeration value="diisel"></enumeration>
<enumeration value="elekter"></enumeration>
</restriction>
</simpleType>
<complexType name="mootorComplexType">
<sequence>
<element name="kytus" type="tns:kytusSimpleType"
maxOccurs="1" minOccurs="0">
</element>
<element name="kubatuur" maxOccurs="1" minOccurs="0">
<complexType>
<simpleContent>
<extension base="int">
<attribute name="yhik" use="required">
<simpleType>
<restriction base="string">
<enumeration value="ccm"/>
<enumeration value="l"/>
</restriction>
</simpleType>
</attribute>
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
</complexType>
<complexType name="autoComplexType">
<sequence>
<element name="mootor" type="tns:mootorComplexType"></element>
<element name="kere" type="tns:kereComplexType"
maxOccurs="1" minOccurs="1">
</element>
</sequence>
<attribute name="id" type="int"></attribute>
<attribute name="mark" type="string"></attribute>
<attribute name="mudel" type="string"></attribute>
</complexType>
<simpleType name="v2rvSimpleType">
<restriction base="string">
<enumeration value="punane"></enumeration>
<enumeration value="roheline"></enumeration>
<enumeration value="sinine"></enumeration>
</restriction>
</simpleType>
<complexType name="kereComplexType">
<attribute name="v2rv" type="tns:v2rvSimpleType"></attribute>
</complexType>
<element name="autod" type="tns:AutodListComplexType"></element>
<complexType name="AutodListComplexType">
<sequence>
<element name="auto" type="tns:autoComplexType" maxOccurs="unbounded" minOccurs="0"></element>
</sequence>
</complexType>
</schema>
XSLT failid
XML -> HTML
<?xml version="1.0" encoding="UTF-8"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tns="http://www.example.org/autod">
<xsl:template match="/">
<html>
<body>
<h2>Autode nimekiri</h2>
<table border="1">
<tr><td>Mark</td><td>Mudel</td><td>Värv</td><td>Mootor</td></tr>
<xsl:for-each select="tns:autod/tns:auto">
<tr>
<td><xsl:value-of select="@mark"/></td>
<td><xsl:value-of select="@mudel"/></td>
<td><xsl:value-of select="tns:kere/@v2rv"/></td>
<td><xsl:value-of select="tns:mootor/tns:kytus"/> <xsl:value-of select="tns:mootor/tns:kubatuur"/><xsl:value-of select="tns:mootor/tns:kubatuur/@yhik"/></td>
</tr>
<p>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>