Meeskond "Kolmas" 2012

From ICO wiki
Jump to navigationJump to search

Meeskond

  • Liikmed: Jevgeni Nesterenko, Jako Heinmets, Lauri Rooden

Idee

Märkmete jagamise teenus. Leides internetist huvitava veebilehe, saab kasutaja bookmarkletil klikates seda koos kommentaariga sõpradele jagada. Kasutajad saavad neile jagatud märkmeid sirvida sarnaselt uudistevoole.


XML fail

http://enos.itcollege.ee/~lrooden/v_rak_2/notes.xml

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="kolmas.xslt"?>
<notes>
  <note>
    <id>dcf0e99</id>
    <url>https://wiki.itcollege.ee/</url>
    <users>
      <user>
        <time>2012-04-03T15:40</time>
        <name>Lauri Rooden</name>
        <comment><![CDATA[Kooli wiki]]></comment>
        <tags>
          <tag>kool</tag>
        </tags>
      </user>
      <user>
        <time>2012-04-03T15:41</time>
        <name>Jako Heinmets</name>
        <comment><![CDATA[ITK wiki]]></comment>
        <tags>
          <tag>ITK</tag>
          <tag>wiki</tag>
        </tags>
      </user>
    </users>
  </note>
  <note>
    <id>25de837</id>
    <url>https://wiki.itcollege.ee/index.php/Meeskond_"Kolmas"</url>
    <users>
      <user>
        <time>2012-04-03T15:41</time>
        <name>Lauri Rooden</name>
        <comment><![CDATA[Kodutoo wikileht]]></comment>
        <tags>
          <tag>kool</tag>
        </tags>
      </user>
    </users>
  </note>
</notes>

XSD fail

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="notes">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="note" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="id" type="xs:string" />
              <xs:element name="url" type="xs:string" />
              <xs:element name="users">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="user" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="time" type="xs:string" />
                          <xs:element name="name" type="xs:string" />
                          <xs:element name="comment" type="xs:string" />
                          <xs:element name="tags">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="tag" type="xs:string" maxOccurs="unbounded" />
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT failid

HTML-i genereerimiseks

<?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>
        <h1>Notes</h1>
        <ul>
          <xsl:for-each select="notes/note">
            <li>
              <h2><xsl:value-of select="url"/></h2>
              <ul>
                <xsl:for-each select="users/user">
                  <li><b><xsl:value-of select="name"/>: </b><xsl:value-of select="comment"/></li>
                </xsl:for-each>
              </ul>
              <h3>Tags</h3>
              <ul>
                <xsl:for-each select="users/user/tags/tag">
                  <xsl:sort select="."/>
                  <li><xsl:value-of select="."/></li>
                </xsl:for-each>
              </ul>
            </li>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

XML formaadi muutmiseks

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/notes">
    <urls>
      <xsl:apply-templates select="note"/>
    </urls>
  </xsl:template>
  <xsl:template match="note">
    <url id="{id}">
      <xsl:value-of select="url" />
    </url>
  </xsl:template>
</xsl:stylesheet>