VRFeeds
From ICO wiki
Tiimi liige
- Tarmo Sillajõe
Kasutatavad tehnoloogiad
Täiendatakse jooksvalt
XML
Rakenduse kirjeldus
Eesmärgiks luua RSS voogude haldusteenus:
- kasutaja saab teenuses RSS vooge lisada ja kustudada
- kasutaja saab pärida talle huvipakkuvate voogude viimaseid uudiseid
- luua võimalus ühele kasutajale (või erinevatele kasutajagruppidele) maksimumpäringute hulga määramiseks
- kasutaja saab RSS vooge vaadata eraldi või grupeeritult
- vooge peab puhverdama, kuna voogude lugemine võtab enamasti üsna palju aega
XML/XSD/XSLT
XML
<?xml version="1.0" encoding="utf-8" ?> <subscriptions> <feed_categories> <feed_category>technology</feed_category> <feed_category>sports</feed_category> <feed_category>politics</feed_category> <feed_category>economy</feed_category> <feed_category>entertainment</feed_category> <feed_category>local</feed_category> <feed_category>educational</feed_category> </feed_categories> <user id="1"> <user-name><![CDATA[jaan.fiktiivne@itcollege.ee]]></user-name> <group_id><![CDATA[student]]></group_id> <feeds max_number="6"> <feed id="1" active="yes"> <feed_category>local</feed_category> <feed_category>politics</feed_category> <feed_description><![CDATA[Postimees]]></feed_description> <feed_url>http://www.postimees.ee/rss/</feed_url> <no_of_episodes>10</no_of_episodes> </feed> <feed id="2" active="yes"> <feed_category>technology</feed_category> <feed_description><![CDATA[Digitund]]></feed_description> <feed_url>http://raadio1.ee/digitund/feed/</feed_url> <no_of_episodes>10</no_of_episodes> </feed> <feed id="3" active="yes"> <feed_category>economy</feed_category> <feed_description><![CDATA[Bloomberg]]></feed_description> <feed_url>http://www.newslookup.com/rss/business/bloomberg.rss</feed_url> <no_of_episodes>10</no_of_episodes> </feed> </feeds> </user> <user id="2"> <user-name><![CDATA[jyri@mingimail.ee]]></user-name> <group_id><![CDATA[child]]></group_id> <feeds max_number="6"> <feed id="1" active="yes"> <feed_category>educational</feed_category> <feed_category>entertainment</feed_category> <feed_description><![CDATA[Educational Documentaries]]></feed_description> <feed_url>https://www.youtube.com/channel/UCLvs-IJf0B2T2v8hzy2zhEg</feed_url> <no_of_episodes>10</no_of_episodes> </feed> </feeds> </user> <user id="3"> <user-name><![CDATA[mari@mingimail.ee]]></user-name> <group_id><![CDATA[student]]></group_id> <feeds max_number="6"> <feed id="1" active="yes"> <feed_category>educational</feed_category> <feed_category>technology</feed_category> <feed_category>entertainment</feed_category> <feed_description><![CDATA[Air Crash Investigation]]></feed_description> <feed_url>https://www.youtube.com/channel/UCIsX1NI5W05MU0eKlhVwm8g</feed_url> <no_of_episodes>10</no_of_episodes> </feed> </feeds> </user> </subscriptions>
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="subscriptions"> <xs:complexType> <xs:sequence> <xs:element name="feed_categories"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="40" name="feed_category" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element maxOccurs="unbounded" name="user"> <xs:complexType> <xs:sequence> <xs:element name="user-name" type="xs:string" /> <xs:element name="group_id" type="xs:string" /> <xs:element name="feeds"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="feed"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="feed_category" type="xs:string" /> <xs:element name="feed_description" type="xs:string" /> <xs:element name="feed_url" type="xs:string" /> <xs:element name="no_of_episodes" type="xs:unsignedByte" /> </xs:sequence> <xs:attribute name="id" type="xs:unsignedByte" use="required" /> <xs:attribute name="active" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="max_number" type="xs:unsignedByte" use="required" /> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="id" type="xs:unsignedByte" use="required" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
XSLT
Näitame kõiki kasutajaid ja nende tellimusi.
<?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="/"> <xsl:param name="filter">""</xsl:param> <html> <head> <title>Kõik kasutajad</title> </head> <body> <p> <h3> <xsl:for-each select="/subscriptions/user"> <!-- valime järjest tsüklis kõik ROOM elemendid --> id: <xsl:value-of select="@id"/>; <br/> user-name: <xsl:value-of select="user-name"/>; <br/> group: <xsl:value-of select="group_id"/>; <br/> max number of feeds allowed: <xsl:value-of select="feeds/@max_number"/> <table border="1"> <tr> <th> description </th> <th> url </th> <th> feed_category </th> </tr> <xsl:for-each select="feeds/feed"> <tr> <td valign="top"> <xsl:value-of select="feed_description"/> </td> <td valign="top"> <xsl:value-of select="feed_url"/> </td> <td > <xsl:for-each select="feed_category"> <li> <xsl:value-of select="."/> </li> </xsl:for-each> </td> </tr> </xsl:for-each > </table> <br></br> <br></br> </xsl:for-each> </h3> </p> </body> </html> </xsl:template> </xsl:stylesheet>
Näitame kasutajaid, kes on omale tellinud tehnoloogiateemalised vood
<?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="/"> <xsl:param name="search_category">technology</xsl:param> <html> <head> <title>valitud kasutajad</title> </head> <body> <xsl:for-each select="/subscriptions/user"> <xsl:variable name="outer" select="."></xsl:variable> <xsl:for-each select="feeds/feed/feed_category"> <xsl:if test=".=$search_category"> <h3> <xsl:value-of select="$outer/user-name"/> </h3> </xsl:if> </xsl:for-each> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
Leiame, kui palju on igal kasutajal aktiivseid voogude tellimusi.
<?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="/"> <xsl:param name="search_category">technology</xsl:param> <html> <head> <title>feedide arv kasutaja kohta</title> </head> <body> <h3> <xsl:for-each select="/subscriptions/user"> Kasutajal <xsl:value-of select="./user-name"/> on aktiivseid feed'isid: <xsl:value-of select="count(feeds/feed[@active='yes'])" /> <br></br> </xsl:for-each> </h3> </body> </html> </xsl:template> </xsl:stylesheet>
Logi
- 03-04 XML'i, skeemifaili ja transformatsioonide loomine.