|
|
Line 35: |
Line 35: |
|
| |
|
| ==Tehnoloogia== | | ==Tehnoloogia== |
|
| |
|
| |
|
| |
| ==XML==
| |
| ''NB! Ei põhine täpselt projekti baasil''
| |
| ===XML File===
| |
| <source lang="xml">
| |
| <?xml version="1.0" encoding="utf-8"?>
| |
| <Users>
| |
| <User id="101" userType="1" authType="3">
| |
| <Username autoGenerated="0">ChineseHaxor420</Username>
| |
| <FirstName>Chung</FirstName>
| |
| <SurName>Lee</SurName>
| |
| <Birthday>1970-01-01</Birthday>
| |
| <Posts>
| |
| <Post id="402" category="6">
| |
| <Image>1021342352435.webp</Image>
| |
| <Description>
| |
| <![CDATA[Funny cat]]>
| |
| </Description>
| |
| <Time>2018-04-11T09:21:04</Time>
| |
| <Comments>
| |
| <Comment id="3423" uid="432">
| |
| <Time>2018-04-12T20:12:31</Time>
| |
| <Body>
| |
| <![CDATA[Awesome!]]>
| |
| </Body>
| |
| </Comment>
| |
| </Comments>
| |
| </Post>
| |
| <Post id="352" category="1">
| |
| <Image>1023423452444.png</Image>
| |
| <Description>
| |
| <![CDATA[Hilarious crash]]>
| |
| </Description>
| |
| <Time>2017-12-15T12:23:01</Time>
| |
| <Comments>
| |
| </Comments>
| |
| </Post>
| |
| </Posts>
| |
| </User>
| |
| <User id="432" userType="2" authType="1">
| |
| <Username autoGenerated="0">AfricanNinja1337</Username>
| |
| <FirstName>Jabul</FirstName>
| |
| <SurName>Kongo</SurName>
| |
| <Birthday>1991-11-03</Birthday>
| |
| <Posts>
| |
| <Post id="212" category="2">
| |
| <Image>10234534534534.jpg</Image>
| |
| <Description>
| |
| <![CDATA[Dis how we drive in Africa!]]>
| |
| </Description>
| |
| <Time>2017-02-02T23:44:53</Time>
| |
| <Comments>
| |
| <Comment id="3423" uid="149">
| |
| <Time>2017-02-02T00:07:18</Time>
| |
| <Body>
| |
| <![CDATA[Haha you guys are broke af]]>
| |
| </Body>
| |
| </Comment>
| |
| </Comments>
| |
| </Post>
| |
| <Post id="653" category="3">
| |
| <Image>1026754745745.jpg</Image>
| |
| <Description>
| |
| <![CDATA[Me and mah Frehnds]]>
| |
| </Description>
| |
| <Time>2018-01-25T04:44:22</Time>
| |
| <Comments>
| |
| <Comment id="1032" uid="101">
| |
| <Time>2018-01-25T05:01:43</Time>
| |
| <Body>
| |
| <![CDATA[Is this lion lurking in the background?]]>
| |
| </Body>
| |
| </Comment>
| |
| <Comment id="1643" uid="145" replyToId="1032">
| |
| <Time>2018-01-25T07:27:16</Time>
| |
| <Body>
| |
| <![CDATA[@101 LOL only in Africa]]>
| |
| </Body>
| |
| </Comment>
| |
| </Comments>
| |
| </Post>
| |
| </Posts>
| |
| </User>
| |
| <User id="523" userType="2" authType="2">
| |
| <Username autoGenerated="0">DmitriHeadshotEveryone</Username>
| |
| <FirstName>Dmitri</FirstName>
| |
| <SurName>Sidorov</SurName>
| |
| <Birthday>1995-05-09</Birthday>
| |
| <Posts>
| |
| <Post id="212" category="9">
| |
| <Image>1023452344234.jpg</Image>
| |
| <Description>
| |
| <![CDATA[In soviet russia...]]>
| |
| </Description>
| |
| <Time>2015-06-11T12:24:51</Time>
| |
| <Comments>
| |
| <Comment id="1273" uid="101">
| |
| <Time>2015-06-11T15:12:33</Time>
| |
| <Body>
| |
| <![CDATA[lmao]]>
| |
| </Body>
| |
| </Comment>
| |
| <Comment id="1211" uid="432">
| |
| <Time>2015-06-11T17:24:10</Time>
| |
| <Body>
| |
| <![CDATA[Putin best]]>
| |
| </Body>
| |
| </Comment>
| |
| <Comment id="1532" uid="523">
| |
| <Time>2015-06-11T22:50:49</Time>
| |
| <Body>
| |
| <![CDATA[rofl]]>
| |
| </Body>
| |
| </Comment>
| |
| </Comments>
| |
| </Post>
| |
| </Posts>
| |
| </User>
| |
| </Users>
| |
| </source>
| |
|
| |
|
| |
| ===XML Schema===
| |
| <source lang="xml">
| |
| <?xml version="1.0" encoding="UTF-8" ?>
| |
| <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
| |
| <xs:element name="Users">
| |
| <xs:complexType>
| |
| <xs:sequence>
| |
| <xs:element name="User" minOccurs="0" maxOccurs="unbounded">
| |
| <xs:complexType>
| |
| <xs:sequence>
| |
| <xs:element name="Username">
| |
| <xs:complexType>
| |
| <xs:simpleContent>
| |
| <xs:extension base="xs:string">
| |
| <xs:attribute name="autoGenerated" type="xs:boolean" use="required"/>
| |
| </xs:extension>
| |
| </xs:simpleContent>
| |
| </xs:complexType>
| |
| </xs:element>
| |
| <xs:element name="FirstName" type="xs:string"/>
| |
| <xs:element name="SurName" type="xs:string"/>
| |
| <xs:element name="Birthday" type="xs:date"/>
| |
| <xs:element name="Posts">
| |
| <xs:complexType>
| |
| <xs:sequence>
| |
| <xs:element name="Post" minOccurs="0" maxOccurs="unbounded">
| |
| <xs:complexType>
| |
| <xs:sequence>
| |
| <xs:element name="Image" type="xs:string"/>
| |
| <!-- Pildi viide, failinimi string -->
| |
| <xs:element name="Description" type="xs:string"/>
| |
| <xs:element name="Time" type="xs:dateTime"/>
| |
| <xs:element name="Comments">
| |
| <xs:complexType>
| |
| <xs:sequence>
| |
| <xs:element name="Comment" minOccurs="0" maxOccurs="unbounded">
| |
| <xs:complexType>
| |
| <xs:sequence>
| |
| <xs:element name="Time" type="xs:dateTime"/>
| |
| <xs:element name="Body" type="xs:string"/>
| |
| </xs:sequence>
| |
| <xs:attribute name="id" type="xs:integer" use="required"/>
| |
| <xs:attribute name="uid" type="xs:integer" use="required"/>
| |
| <xs:attribute name="replyToId" type="xs:integer"/>
| |
| </xs:complexType>
| |
| </xs:element>
| |
| </xs:sequence>
| |
| </xs:complexType>
| |
| </xs:element>
| |
| </xs:sequence>
| |
| <xs:attribute name="id" type="xs:integer" use="required"/>
| |
| <xs:attribute name="category" type="xs:integer" use="required"/>
| |
| </xs:complexType>
| |
| </xs:element>
| |
| </xs:sequence>
| |
| </xs:complexType>
| |
| </xs:element>
| |
| </xs:sequence>
| |
| <xs:attribute name="id" type="xs:integer" use="required"/>
| |
| <xs:attribute name="userType" type="xs:integer" use="required"/>
| |
| <xs:attribute name="authType" type="xs:integer" use="required"/>
| |
| </xs:complexType>
| |
| </xs:element>
| |
| </xs:sequence>
| |
| </xs:complexType>
| |
| </xs:element>
| |
| </xs:schema>
| |
| </source>
| |
|
| |
|
| |
| ===XML HTML Transformation vol 1===
| |
| Tulemust näeb [http://enos.itcollege.ee/~mkildema/VRII/andmefail1.xml siin]
| |
| <source lang="xml">
| |
| <?xml version="1.0" encoding="utf-8"?>
| |
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| |
| <xsl:template match="/">
| |
| <html>
| |
| <body>
| |
| <h3>User list</h3>
| |
| <ul>
| |
| <xsl:for-each select="Users/User">
| |
| <!-- valime järjest tsüklis kõik kasutajad ning kuvame andmed -->
| |
| <li>
| |
| <i>
| |
| <xsl:value-of select="@id"/>
| |
| </i>
| |
| <xsl:if test="@userType = 1">
| |
| <!-- kui kasutaja level on VIP -->
| |
| ☆ <!-- kuvame sümbolit -->
| |
| </xsl:if>
| |
| <br/>
| |
| <strong>Username: </strong>
| |
| <xsl:value-of select="Username"/>
| |
| <br/>
| |
| <strong>Displayname: </strong>
| |
| <xsl:value-of select="substring(FirstName, 1, 2)"/>
| |
| <xsl:value-of select="substring(SurName, 1, 4)"/>
| |
| <!-- genereerime kuvanime sarnaselt TTÜ Uni-ID-ga (2 esimest eesnime tähte ning 4 perekonnanimest) -->
| |
| <br/>
| |
| <strong>Posts: </strong>
| |
| <xsl:value-of select="count(Posts/Post)"/>
| |
| <!-- palju on kasutajal postitusi -->
| |
| <br/>
| |
| <xsl:if test="@authType = 3">
| |
| <!-- kui kasutaja registreeritud läbi facebooki -->
| |
| <a href="http://facebook.com/{Username}" target="_blank">Facebook profile</a> <!-- kuvame tema profiili linki -->
| |
| </xsl:if>
| |
| <br/><br/>
| |
| </li>
| |
| </xsl:for-each>
| |
| </ul>
| |
| </body>
| |
| </html>
| |
| </xsl:template>
| |
| </xsl:stylesheet>
| |
| </source>
| |
|
| |
| ===XML HTML Transformation vol 2===
| |
| Tulemust näeb [http://enos.itcollege.ee/~mkildema/VRII/andmefail2.xml siin]
| |
| <source lang="xml">
| |
| <?xml version="1.0" encoding="utf-8"?>
| |
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| |
| <xsl:template match="/">
| |
| <html>
| |
| <body>
| |
| <h3>Post list</h3>
| |
| <xsl:for-each select="Users/User/Posts/Post">
| |
| <!-- valime järjest tsüklis kõik postitused ning kuvame andmed -->
| |
| <br/>
| |
| <strong>Description: </strong>
| |
| <xsl:value-of select="Description"/>
| |
| <br/>
| |
| <img src="img/{Image}" height="275"/>
| |
| <br/>
| |
| <ul>
| |
| <strong>Comments: </strong> <!-- palju on postitusel kommentaare -->
| |
| <xsl:choose>
| |
| <xsl:when test="count(Comments/Comment) = 0">
| |
| <div style="color:red;display:inline;">
| |
| <xsl:value-of select="count(Comments/Comment)"/>
| |
| </div>
| |
| <!-- kuva punaselt, kui pole kommentaare -->
| |
| </xsl:when>
| |
| <xsl:otherwise>
| |
| <xsl:value-of select="count(Comments/Comment)"/>
| |
| <!-- kuva tavaliselt kui on -->
| |
| </xsl:otherwise>
| |
| </xsl:choose>
| |
| <br/><br/>
| |
| <xsl:for-each select="Comments/Comment">
| |
| <!-- valime kõik kommentaarid ning kuvame -->
| |
| <xsl:sort select="Time"/>
| |
| <!-- sorteerime aja järgi -->
| |
| <li>
| |
| <strong>
| |
| <xsl:value-of select="@uid"/>
| |
| says:
| |
| </strong>
| |
| <br/>
| |
| <xsl:value-of select="Body"/>
| |
| </li>
| |
| </xsl:for-each>
| |
| </ul>
| |
| <br/>
| |
| <hr/>
| |
| <br/>
| |
| </xsl:for-each>
| |
| </body>
| |
| </html>
| |
| </xsl:template>
| |
| </xsl:stylesheet>
| |
| </source>
| |