2017 Meeskond Poly: Difference between revisions
From ICO wiki
Jump to navigationJump to search
XML sisu - tuulepark |
m meetodi nimi. |
||
(7 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
<parks> | <parks> | ||
<park id="1"> | <park id="1"> | ||
<name> | <name>SUDENAI</name> | ||
<country iso=" | <country iso="LIT">Lithuania</country> | ||
<wind unit="m/s">1.7</wind> | <wind unit="m/s">1.7</wind> | ||
<power unit="kWh"> | <power unit="kWh"> | ||
<now>0</now> | <now>0.3</now> | ||
<month>2700</month> | <month>2700</month> | ||
<year>48275</year> | <year>48275</year> | ||
Line 74: | Line 74: | ||
==== XSD ==== | ==== XSD ==== | ||
<pre> | <pre> | ||
<?xml version="1.0" encoding="utf-8"?> | |||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |||
<xs:element name="parks"> | |||
<xs:complexType> | |||
<xs:sequence> | |||
<xs:element name="park"> | |||
<xs:complexType> | |||
<xs:sequence> | |||
<xs:element name="name" type="xs:string" /> | |||
<xs:element name="country"> | |||
<xs:complexType> | |||
<xs:simpleContent> | |||
<xs:extension base="xs:string"> | |||
<xs:attribute name="iso" type="xs:string" use="required" /> | |||
</xs:extension> | |||
</xs:simpleContent> | |||
</xs:complexType> | |||
</xs:element> | |||
<xs:element name="wind"> | |||
<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 name="power"> | |||
<xs:complexType> | |||
<xs:sequence> | |||
<xs:element name="now" type="xs:decimal" /> | |||
<xs:element name="month" type="xs:unsignedShort" /> | |||
<xs:element name="year" type="xs:unsignedInt" /> | |||
</xs:sequence> | |||
<xs:attribute name="unit" type="xs:string" use="required" /> | |||
</xs:complexType> | |||
</xs:element> | |||
<xs:element name="turbines"> | |||
<xs:complexType> | |||
<xs:sequence> | |||
<xs:element name="active" type="xs:unsignedShort" /> | |||
<xs:element name="total" type="xs:unsignedShort" /> | |||
<xs:element 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: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> | |||
</pre> | </pre> | ||
==== XSLT HTML ==== | ==== XSLT HTML ==== | ||
<pre> | <pre> | ||
<?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> | |||
<h2>Wind parks in Estonia</h2> | |||
<table border="1"> | |||
<tr bgcolor="#9acd32"> | |||
<th>Name</th> | |||
<th>Wind speed</th> | |||
<th>Power</th> | |||
<th>Turbines</th> | |||
<th>Annual</th> | |||
</tr> | |||
<xsl:for-each select="parks/park"> | |||
<xsl:sort select="name"/> | |||
<xsl:if test="country/@iso = 'EST'"> | |||
<tr> | |||
<xsl:attribute name="id"> | |||
<xsl:value-of select="concat('park_',@id)"/> | |||
</xsl:attribute> | |||
<td> | |||
<xsl:value-of select="name"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="concat(wind, ' ', wind/@unit)"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="power/now"/> | |||
<xsl:value-of select="power/@unit"/> | |||
<xsl:value-of select="concat(' of ',turbines/power)"/> | |||
<xsl:value-of select="turbines/power/@unit"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="turbines/active"/>/<xsl:value-of select="turbines/total"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="power/year"/> | |||
<xsl:value-of select="substring(power/@unit,1,2)"/> | |||
</td> | |||
</tr> | |||
</xsl:if> | |||
</xsl:for-each> | |||
</table> | |||
</body> | |||
</html> | |||
</xsl:template> | |||
</xsl:stylesheet> | |||
</pre> | </pre> | ||
==== XSLT XML ==== | ==== XSLT XML ==== | ||
Teeb kokkuvõtte riigiti, liites grupiti kokku turbiinide ja nendes toodetud elektri väärtused. | |||
Kasutatud Muenchian Meetodit | |||
<pre> | <pre> | ||
<?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:key name="parks-by-country" | |||
match="park" | |||
use="country/@iso"/> | |||
<xsl:template match="parks"> | |||
<countries> | |||
<xsl:for-each select="park[count(. | key('parks-by-country', country/@iso)[1]) = 1]"> | |||
<country> | |||
<name> | |||
<xsl:value-of select="country"/> | |||
</name> | |||
<power> | |||
<xsl:value-of select="sum(key('parks-by-country',country/@iso)/power/now)"/> | |||
</power> | |||
<turbines> | |||
<active> | |||
<xsl:value-of select="sum(key('parks-by-country',country/@iso)/turbines/active)"/> | |||
</active> | |||
<total> | |||
<xsl:value-of select="sum(key('parks-by-country',country/@iso)/turbines/total)"/> | |||
</total> | |||
</turbines> | |||
<parks> | |||
<xsl:for-each select="key('parks-by-country',country/@iso)"> | |||
<park> | |||
<xsl:value-of select="name"/> | |||
</park> | |||
</xsl:for-each> | |||
</parks> | |||
</country> | |||
</xsl:for-each> | |||
</countries> | |||
</xsl:template> | |||
</xsl:stylesheet> | |||
</pre> | </pre> | ||
Tulemus | |||
<pre> | |||
<countries> | |||
<country> | |||
<name>Lithuania</name> | |||
<power>0.3</power> | |||
<turbines> | |||
<active>7</active> | |||
<total>8</total> | |||
</turbines> | |||
<parks> | |||
<park>SUDENAI</park> | |||
</parks> | |||
</country> | |||
<country> | |||
<name>Estonia</name> | |||
<power>3.5</power> | |||
<turbines> | |||
<active>28</active> | |||
<total>29</total> | |||
</turbines> | |||
<parks> | |||
<park>Paldiski</park> | |||
<park>Tooma I</park> | |||
<park>Tooma II</park> | |||
</parks> | |||
</country> | |||
</countries> | |||
</pre> | |||
=== Retsensioonid === | === Retsensioonid === | ||
...TODO | ...TODO |
Latest revision as of 23:19, 19 March 2017
Meeskond
- Kristian Kalm
- Roland Kontson
XML
Dokumendid
XML
<?xml version="1.0" encoding="utf-8" ?> <parks> <park id="1"> <name>SUDENAI</name> <country iso="LIT">Lithuania</country> <wind unit="m/s">1.7</wind> <power unit="kWh"> <now>0.3</now> <month>2700</month> <year>48275</year> </power> <turbines> <active>7</active> <total>8</total> <power unit="kWh">24</power> </turbines> </park> <park id="2"> <name>Paldiski</name> <country iso="EST">Estonia</country> <wind unit="m/s">3</wind> <power unit="kWh"> <now>0.2</now> <month>6400</month> <year>80224</year> </power> <turbines> <active>17</active> <total>18</total> <power unit="kWh">45</power> </turbines> </park> <park id="3"> <name>Tooma I</name> <country iso="EST">Estonia</country> <wind unit="m/s">5.3</wind> <power unit="kWh"> <now>2.1</now> <month>2500</month> <year>33317</year> </power> <turbines> <active>8</active> <total>8</total> <power unit="kWh">16</power> </turbines> </park> <park id="4"> <name>Tooma II</name> <country iso="EST">Estonia</country> <wind unit="m/s">5.2</wind> <power unit="kWh"> <now>1.2</now> <month>999</month> <year>9170</year> </power> <turbines> <active>3</active> <total>3</total> <power unit="kWh">7</power> </turbines> </park> </parks>
XSD
<?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="parks"> <xs:complexType> <xs:sequence> <xs:element name="park"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string" /> <xs:element name="country"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="iso" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="wind"> <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 name="power"> <xs:complexType> <xs:sequence> <xs:element name="now" type="xs:decimal" /> <xs:element name="month" type="xs:unsignedShort" /> <xs:element name="year" type="xs:unsignedInt" /> </xs:sequence> <xs:attribute name="unit" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element name="turbines"> <xs:complexType> <xs:sequence> <xs:element name="active" type="xs:unsignedShort" /> <xs:element name="total" type="xs:unsignedShort" /> <xs:element 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: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
<?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> <h2>Wind parks in Estonia</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Name</th> <th>Wind speed</th> <th>Power</th> <th>Turbines</th> <th>Annual</th> </tr> <xsl:for-each select="parks/park"> <xsl:sort select="name"/> <xsl:if test="country/@iso = 'EST'"> <tr> <xsl:attribute name="id"> <xsl:value-of select="concat('park_',@id)"/> </xsl:attribute> <td> <xsl:value-of select="name"/> </td> <td> <xsl:value-of select="concat(wind, ' ', wind/@unit)"/> </td> <td> <xsl:value-of select="power/now"/> <xsl:value-of select="power/@unit"/> <xsl:value-of select="concat(' of ',turbines/power)"/> <xsl:value-of select="turbines/power/@unit"/> </td> <td> <xsl:value-of select="turbines/active"/>/<xsl:value-of select="turbines/total"/> </td> <td> <xsl:value-of select="power/year"/> <xsl:value-of select="substring(power/@unit,1,2)"/> </td> </tr> </xsl:if> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
XSLT XML
Teeb kokkuvõtte riigiti, liites grupiti kokku turbiinide ja nendes toodetud elektri väärtused. Kasutatud Muenchian Meetodit
<?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:key name="parks-by-country" match="park" use="country/@iso"/> <xsl:template match="parks"> <countries> <xsl:for-each select="park[count(. | key('parks-by-country', country/@iso)[1]) = 1]"> <country> <name> <xsl:value-of select="country"/> </name> <power> <xsl:value-of select="sum(key('parks-by-country',country/@iso)/power/now)"/> </power> <turbines> <active> <xsl:value-of select="sum(key('parks-by-country',country/@iso)/turbines/active)"/> </active> <total> <xsl:value-of select="sum(key('parks-by-country',country/@iso)/turbines/total)"/> </total> </turbines> <parks> <xsl:for-each select="key('parks-by-country',country/@iso)"> <park> <xsl:value-of select="name"/> </park> </xsl:for-each> </parks> </country> </xsl:for-each> </countries> </xsl:template> </xsl:stylesheet>
Tulemus
<countries> <country> <name>Lithuania</name> <power>0.3</power> <turbines> <active>7</active> <total>8</total> </turbines> <parks> <park>SUDENAI</park> </parks> </country> <country> <name>Estonia</name> <power>3.5</power> <turbines> <active>28</active> <total>29</total> </turbines> <parks> <park>Paldiski</park> <park>Tooma I</park> <park>Tooma II</park> </parks> </country> </countries>
Retsensioonid
...TODO
Veebiteenus
...TODO
Klientrakendused
...TODO