Hops: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
|||
Line 169: | Line 169: | ||
==== XML -> XML ==== | ==== XML -> XML ==== | ||
<source lang="xml"> | <source lang="xml"> | ||
xxx | |||
</source lang="xml"> | </source lang="xml"> | ||
Revision as of 21:47, 15 April 2013
Meeskond
- Liikmed:
- Artur Hokkonen
- Margus Parts
- Hanno Sirkel
- Lauri Õunmaa
Idee
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
<source lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <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>
Autode nimekiri
<xsl:for-each select="tns:autod/tns:auto">
Mark | Mudel | Värv | Mootor |
<xsl:value-of select="@mark"/> | <xsl:value-of select="@mudel"/> | <xsl:value-of select="tns:kere/@v2rv"/> | <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"/> |
</xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> </source lang="xml">
XML -> XML
<source lang="xml"> xxx </source lang="xml">