Liisa ja Poisid
From ICO wiki
Meeskonna liikmed
- Liisa Suurkaev
- Tõnis Suurkaev
- Maanus Indov
XML
Trenni graafik
<?xml version="1.0" encoding="utf-8" ?>
<users>
<user userId="u1">
<userData>
<firstName><![CDATA[Peter]]></firstName>
<lastName><![CDATA[Griffin]]></lastName>
<contact type="mobile"><![CDATA[55678942]]></contact>
<contact type="skype"><![CDATA[peeeter]]></contact>
</userData>
<year yearId="2015">
<month monthId="2">
<day dayId="28">
<practice startHour="18" startMinutes="00" endHour="21" endMinutes="00" weight="90">
<type><![CDATA[Kõht]]></type>
<lostCalories><![CDATA[]]>0</lostCalories>
<userComments><![CDATA[That was the best workout ever!]]></userComments>
</practice>
</day>
<day dayId="28">
<practice startHour="18" startMinutes="00" endHour="21" endMinutes="00" weight="91">
<type><![CDATA[Vastupidavus]]></type>
<lostCalories><![CDATA[1950]]></lostCalories>
</practice>
</day>
</month>
<month monthId="3">
<day dayId="1">
<practice startHour="19" startMinutes="00" endHour="21" endMinutes="30" weight="90">
<type><![CDATA[Zumba]]></type>
<lostCalories><![CDATA[490]]></lostCalories>
</practice>
</day>
<day dayId="3">
<practice startHour="19" startMinutes="00" endHour="21" endMinutes="30" weight="88">
<type><![CDATA[Jalad]]></type>
<lostCalories><![CDATA[1490]]></lostCalories>
</practice>
</day>
</month>
</year>
</user>
<user userId="u2">
<userData>
<firstName><![CDATA[Homer]]></firstName>
<lastName><![CDATA[Simpson]]></lastName>
<contact type="skype"><![CDATA[homsim]]></contact>
</userData>
<year yearId="2015">
<month monthId="2">
<day dayId="26">
<practice startHour="18" startMinutes="00" endHour="21" endMinutes="00" weight="85">
<type><![CDATA[Zumba]]></type>
<lostCalories><![CDATA[1980]]></lostCalories>
</practice>
</day>
<day dayId="28">
<practice startHour="18" startMinutes="00" endHour="21" endMinutes="00" weight="86">
<type><![CDATA[Vastupidavus]]></type>
<lostCalories><![CDATA[2000]]></lostCalories>
</practice>
</day>
</month>
<month monthId="3">
<day dayId="1">
<practice startHour="19" startMinutes="00" endHour="21" endMinutes="30" weight="86">
<type><![CDATA[Käed]]></type>
<lostCalories><![CDATA[200]]></lostCalories>
</practice>
</day>
</month>
</year>
</user>
</users>
XML skeemifail
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="users">
<xs:complexType>
<xs:sequence>
<xs:element name="user" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="userData">
<xs:complexType>
<xs:sequence>
<xs:element name="firstName" type="xs:string" />
<xs:element name="lastName" type="xs:string" />
<xs:element maxOccurs="unbounded" name="contact">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="type" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="year" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="month">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="day">
<xs:complexType>
<xs:sequence>
<xs:element name="practice">
<xs:complexType>
<xs:sequence>
<xs:element name="type" type="xs:string" />
<xs:element name="lostCalories" type="positiveInt" />
<xs:element name="userComments" type="xs:string" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="startHour" type="dateType" use="required" />
<xs:attribute name="startMinutes" type="dateType" use="required" />
<xs:attribute name="endHour" type="dateType" use="required" />
<xs:attribute name="endMinutes" type="dateType" use="required" />
<xs:attribute name="weight" type="positiveInt" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="dayId" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="monthId" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="yearId" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="userId" type="xs:ID" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="positiveInt">
<xs:union>
<xs:simpleType>
<xs:restriction base='xs:string'>
<xs:length value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base='xs:integer'>
<xs:minInclusive value="0"></xs:minInclusive>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="dateType">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"></xs:minInclusive>
<xs:maxInclusive value="59"></xs:maxInclusive>
</xs:restriction>
</xs:simpleType>
</xs:schema>
XML Transformatsioonid
Xslt to 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>
<head></head>
<body>
<xsl:for-each select="users/user">
<h1>User information</h1>
<p>
<p>
Name -
<xsl:value-of select="userData/firstName"/><xsl:text> </xsl:text>
<xsl:value-of select="userData/lastName"/>
</p>
<p>
<ul>
<xsl:if test="userData/contact/@type = 'mobile'">
<li>
Phone number: <xsl:value-of select="userData/contact" />
</li>
</xsl:if>
<li>
Number of practices:
<xsl:value-of select="count(year/month/day/practice)"/>
</li>
<li>
Sum of lost calories:
<xsl:value-of select="sum(year/month/day/practice/lostCalories)" />
</li>
<h3>Workout in February 2015</h3>
<xsl:for-each select="year">
<xsl:if test="@yearId = '2015'">
<xsl:for-each select="month">
<xsl:if test="@monthId = '2'">
<xsl:for-each select="day">
<xsl:for-each select="practice">
<li>
February <xsl:value-of select="../@dayId"/>
</li>
<p>
Workout type:
<xsl:value-of select="type" /><br/>
Workout time:
<xsl:value-of select="@endHour - @startHour"/> hours
<xsl:value-of select="@endMinutes - @startMinutes"/> minutes <br/>
<xsl:if test="count(userComments) = 1">
Comments: <xsl:value-of select="userComments"/>
</xsl:if>
</p>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</ul>
</p>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Xslt to xml
<?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="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//month[@monthId!='2']"> </xsl:template>
</xsl:stylesheet>