HMR

From ICO wiki
Jump to navigationJump to search

Idee

Hetkel toimub idee formuleerimine

Meeskond HMR

  • Harles Luts
  • Mattiko Kabanen
  • Ranek Runthal

XML formaadis admeedastus

XML andmefail

<?xml version="1.0" encoding="utf-8" ?>
<Solarsystem>
      <TableHeader>
      <Column id="1" units="">
        <Name lang="eng"><![CDATA[Name]]></Name>
        <Name lang="est"><![CDATA[Nimi]]></Name>
      </Column>
      <Column id="2" units="AU">
        <Name lang="eng"><![CDATA[Distance]]></Name>
        <Name lang="est"><![CDATA[Kaugus]]></Name>
      </Column>
      <Column id="3" units="bar">
        <Name lang="eng"><![CDATA[Pressure on surface]]></Name>
        <Name lang="est"><![CDATA[Rõhk pinnal]]></Name>
      </Column>
      <Column id="4" units="">
        <Name lang="eng"><![CDATA[Components of atmosphere]]></Name>
        <Name lang="est"><![CDATA[Atmosfääri peamised komponendid]]></Name>
      </Column>
      <Column id="5" units="">
        <Name lang="eng"><![CDATA[More information]]></Name>
        <Name lang="est"><![CDATA[Rohem teavet]]></Name>
      </Column>
   </TableHeader>
  <Planets count="8">
   <Planet mass="0.055" unit="em" distfromsun="0.46" dunits="AU">
      <Test>
        <![CDATA[No see on test!!!]]>
      </Test>
      <Name lang="eng">
        <![CDATA[Mercury]]>
      </Name>
      <Name lang="est">
        <![CDATA[Merkuur]]>
      </Name>
      <Atmosphere surfpress="0.001" punit="picobar">
         <Component percent="42" >
          <Name lang="eng"><![CDATA[Oxygen]]></Name>
          <Name lang="est"> <![CDATA[Hapnik]]></Name>
          <ChemElem atoms="2">O</ChemElem>
        </Component>
        <Component percent="29">
          <Name lang="eng">
            <![CDATA[Sodium]]></Name>
          <Name lang="est"><![CDATA[Naatrium]]></Name>
            <ChemElem>Na</ChemElem>
          </Component>
        <Component percent="22">
          <Name lang="eng"><![CDATA[Hydrogen]]></Name>
          <Name lang="est"><![CDATA[Vesinik]]></Name>
          <ChemElem atoms="2">H</ChemElem>
        </Component>
      </Atmosphere>
      <MoreInfo type="weblink">
        <![CDATA[http://nssdc.gsfc.nasa.gov/planetary/factsheet/mercuryfact.html]]>
      </MoreInfo>
    </Planet>
    <!-- ........................................................................... -->
    <Planet mass="0.815" unit="em" distfromsun="0.7" dunits="AU">
      <Name lang="eng">
        <![CDATA[Venus]]>
      </Name>
      <Name lang="est">
        <![CDATA[Veenus]]>
      </Name>
      <Atmosphere surfpress="92" punit="bar">
        <Component percent="96.5">
          <Name lang="eng"><![CDATA[Carbon Dioxide]]></Name>
          <Name lang="est"> <![CDATA[Süsinik dioksiid]]></Name>
          <ChemElem atoms="1">C</ChemElem>
          <ChemElem atoms="2">O</ChemElem>
        </Component>
        <Component percent="3.5">
          <Name lang="est"><![CDATA[Lämmasik]]></Name>
          <Name lang="eng"><![CDATA[Nitrogen]]></Name>
          <ChemElem atoms="2">N</ChemElem>
        </Component>
      </Atmosphere>
      <MoreInfo type="weblink">
        <![CDATA[http://nssdc.gsfc.nasa.gov/planetary/factsheet/venusfact.html]]>
      </MoreInfo>
    </Planet>
    <!-- ........................................................................... -->
    <Planet mass="1.0" unit="em" distfromsun="1.0" dunits="AU">
      <Name lang="eng">
        <![CDATA[Earth]]>
      </Name>
      <Name lang="est">
        <![CDATA[Maa]]>
      </Name>
      <Atmosphere surfpress="1014" punit="mbar">
        <Component percent="78.08">
          <Name lang="eng"><![CDATA[Nitrogen]]></Name>
          <Name lang="est"> <![CDATA[Lämmastik]]></Name>
          <ChemElem atoms="2">N</ChemElem>
        </Component>
        <Component percent="20.95">
          <Name lang="est">
            <![CDATA[Hapnik]]></Name>
          <Name lang="eng"><![CDATA[Oxygen]]></Name>
          <ChemElem atoms="2">O</ChemElem>
        </Component>
      </Atmosphere>
      <MoreInfo type="weblink">
        <![CDATA[http://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html]]>
      </MoreInfo>
    </Planet>
    <!-- ........................................................................... -->
    <Planet mass="0.64174" unit="em" distfromsun="1.5" dunits="AU">
      <Name lang="eng">
        <![CDATA[Mars]]>
      </Name>
      <Name lang="est">
        <![CDATA[Marss]]>
      </Name>
      <Atmosphere surfpress="1014" punit="mbar">
        <Component percent="95.32">
          <Name lang="eng"><![CDATA[Carbon Dioxide]]></Name>
          <Name lang="est"> <![CDATA[Süsinik dioksiid]]></Name>
          <ChemElem atoms="1">C</ChemElem>
          <ChemElem atoms="2">O</ChemElem>
        </Component>
        <Component percent="2.7">
          <Name lang="est"><![CDATA[Lämmastik]]></Name>
          <Name lang="eng"><![CDATA[Nitrogen]]></Name>
          <ChemElem atoms="2">N</ChemElem>
        </Component>
      </Atmosphere>
      <MoreInfo type="weblink">
        <![CDATA[http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html]]>
      </MoreInfo>
    </Planet>
    <!-- ........................................................................... -->
    <Planet mass="318" unit="em" distfromsun="5.2" dunits="AU">
      <Name lang="eng">
        <![CDATA[Jupiter]]>
      </Name>
      <Name lang="est">
        <![CDATA[Jupiter]]>
      </Name>
      <Atmosphere surfpress="1000" punit="bar">
        <Component percent="89.8">
          <Name lang="eng"><![CDATA[Molecular Hydorgen]]></Name>
          <Name lang="est"> <![CDATA[Molekulaarne vesinik]]></Name>
          <ChemElem atoms="2">H</ChemElem>
        </Component>
        <Component percent="10.2">
          <Name lang="est"><![CDATA[Heelium]]></Name>
          <Name lang="eng"><![CDATA[Helium]]></Name>
          <ChemElem atoms="1">He</ChemElem>
        </Component>
      </Atmosphere>
      <MoreInfo type="weblink">
        <![CDATA[http://nssdc.gsfc.nasa.gov/planetary/factsheet/jupiterfact.html]]>
      </MoreInfo>
    </Planet>
    <!-- ........................................................................... -->
    <Planet mass="568" unit="em" distfromsun="9.5" dunits="AU">
      <Name lang="eng">
        <![CDATA[Saturn]]>
      </Name>
      <Name lang="est">
        <![CDATA[Saturn]]>
      </Name>
      <Atmosphere surfpress="1000" punit="bar">
        <Component percent="96.3">
          <Name lang="eng"><![CDATA[Molecular Hydorgen]]></Name>
          <Name lang="est"> <![CDATA[Molekulaarne vesinik]]></Name>
          <ChemElem atoms="2">H</ChemElem>
        </Component>
        <Component percent="3.25">
          <Name lang="est"><![CDATA[Heelium]]></Name>
          <Name lang="eng"><![CDATA[Helium]]></Name>
          <ChemElem atoms="1">He</ChemElem>
        </Component>
      </Atmosphere>
      <MoreInfo type="weblink">
        <![CDATA[http://nssdc.gsfc.nasa.gov/planetary/factsheet/saturnfact.html]]>
      </MoreInfo>
    </Planet>
    <!-- ........................................................................... -->
    <Planet mass="87" unit="em" distfromsun="19.2" dunits="AU">
      <Name lang="eng">
        <![CDATA[Uranus]]>
      </Name>
      <Name lang="est">
        <![CDATA[Uraan]]>
      </Name>
      <Atmosphere surfpress="1000" punit="bar">
        <Component percent="82.5">
          <Name lang="eng"><![CDATA[Molecular Hydorgen]]></Name>
          <Name lang="est"> <![CDATA[Molekulaarne vesinik]]></Name>
          <ChemElem atoms="2">H</ChemElem>
        </Component>
        <Component percent="15.2">
          <Name lang="est"><![CDATA[Heelium]]></Name>
          <Name lang="eng"><![CDATA[Helium]]></Name>
          <ChemElem atoms="1">He</ChemElem>
        </Component>
      </Atmosphere>
      <MoreInfo type="weblink">
        <![CDATA[http://nssdc.gsfc.nasa.gov/planetary/factsheet/uranusfact.html]]>
      </MoreInfo>
    </Planet>
    <!-- ........................................................................... -->
    <Planet mass="568" unit="em" distfromsun="30.1" dunits="AU">
      <Name lang="eng">
        <![CDATA[Neptun]]>
      </Name>
      <Name lang="est">
        <![CDATA[Neptuun]]>
      </Name>
      <Atmosphere surfpress="1000" punit="bar">
        <Component percent="80.0">
          <Name lang="eng"><![CDATA[Molecular Hydorgen]]></Name>
          <Name lang="est"> <![CDATA[Molekulaarne vesinik]]></Name>
          <ChemElem atoms="2">H</ChemElem>
        </Component>
        <Component percent="19.0">
          <Name lang="est"><![CDATA[Heelium]]></Name>
          <Name lang="eng"><![CDATA[Helium]]></Name>
          <ChemElem atoms="1">He</ChemElem>
        </Component>
      </Atmosphere>
      <MoreInfo type="weblink">
        <![CDATA[http://nssdc.gsfc.nasa.gov/planetary/factsheet/neptunefact.html]]>
      </MoreInfo>
    </Planet>
    <!-- ........................................................................... -->
  </Planets>
  <Asteroids>
    <Asteroid>

    </Asteroid>
  </Asteroids>
</Solarsystem>

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="Solarsystem">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="TableHeader">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="Column">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="Name">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="lang" type="xs:string" use="required" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="id" type="xs:unsignedInt" use="required" />
                  <xs:attribute name="units" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Planets">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="Planet">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs="0" name="Test" type="xs:string" />
                    <xs:element maxOccurs="unbounded" name="Name">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="lang" type="xs:string" use="required" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="Atmosphere">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="Component">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element maxOccurs="unbounded" name="Name">
                                  <xs:complexType>
                                    <xs:simpleContent>
                                      <xs:extension base="xs:string">
                                        <xs:attribute name="lang" type="xs:string" use="required" />
                                      </xs:extension>
                                    </xs:simpleContent>
                                  </xs:complexType>
                                </xs:element>
                                <xs:element maxOccurs="unbounded" name="ChemElem">
                                  <xs:complexType>
                                    <xs:simpleContent>
                                      <xs:extension base="xs:string">
                                        <xs:attribute name="atoms" type="xs:unsignedInt" use="optional" />
                                      </xs:extension>
                                    </xs:simpleContent>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                              <xs:attribute name="percent" type="xs:decimal" use="required" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="surfpress" type="xs:decimal" use="required" />
                        <xs:attribute name="punit" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="MoreInfo">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="type" type="xs:string" use="required" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="mass" type="xs:decimal" use="required" />
                  <xs:attribute name="unit" type="xs:string" use="required" />
                  <xs:attribute name="distfromsun" type="xs:decimal" use="required" />
                  <xs:attribute name="dunits" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="count" type="xs:unsignedInt" use="required" />
          </xs:complexType>
        </xs:element>
        <xs:element name="Asteroids">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="Asteroid" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XML transformatsioonifail

XSLT planeetide ülevaatetabeli genereerimiseks

<?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>
        <style type="text/css">
          table, td, th { border: 1px solid gray }
          td {align:center;}
        </style>
        <title>Dummy list of planets</title>
      </head>
        <body>
          <h1>
            <xsl:choose>
            <xsl:when test="Solarsystem/Planets[@lang='est']">
              <![CDATA[Planeetide ülevaade]]>
            </xsl:when>
            <xsl:otherwise>
              <![CDATA[List of planets]]>
            </xsl:otherwise>
            </xsl:choose>
          </h1>
          <table>
            <tr>
              <xsl:for-each select="Solarsystem/TableHeader/Column">
                <th>
                   <xsl:value-of select="Name[@lang='eng']"/>
                  <xsl:if test="@units!=''">
                  (<xsl:value-of select="@units"/>)
                  </xsl:if>
                </th>
              </xsl:for-each>
            </tr>
              <xsl:for-each select="Solarsystem/Planets/Planet">
               <tr>
                <td>
                    <xsl:value-of select="Name[@lang='eng']"/>
                </td>
                <td>
                  <xsl:value-of select="@distfromsun"/>
                </td>
                <td>
                  <xsl:value-of select="Atmosphere/@surfpress"/>
                </td>
                <td>
                  <ul>
                  <xsl:for-each select="Atmosphere/Component">
                    <li>
                      <xsl:value-of select="Name[@lang='eng']"/>
                      (
                      <xsl:for-each select="ChemElem">
                        <xsl:value-of select="."/>
                        <xsl:if test="@atoms &gt; 1">
                          <sub>
                            <xsl:value-of select="@atoms"/>
                        </sub>
                        </xsl:if>
                      </xsl:for-each>
                      )
                      - [<xsl:value-of select="@percent"/>%]
                    </li>                  
                    
                  </xsl:for-each>
                  </ul>
                </td>
                <td>
                  <xsl:element name="a">
                    <xsl:attribute name="href">
                       <xsl:value-of select="MoreInfo"/>
                    </xsl:attribute>
                    <xsl:value-of select="MoreInfo"/>
                  </xsl:element>
                </td>
              </tr>
            </xsl:for-each>
          </table>
          <!--******************************************************************-->
          <h1>
            <xsl:choose>
              <xsl:when test="Solarsystem/Planets[@lang='est']">
                <![CDATA[Siseringi planeedid]]>
              </xsl:when>
              <xsl:otherwise>
                <![CDATA[Planets of inner circle]]>
              </xsl:otherwise>
            </xsl:choose>
          </h1>
          <table>
            <tr>
              <xsl:for-each select="Solarsystem/TableHeader/Column">
                <th>
                  <xsl:value-of select="Name[@lang='eng']"/>
                  <xsl:if test="@units!=''">
                    (<xsl:value-of select="@units"/>)
                  </xsl:if>
                </th>
              </xsl:for-each>
            </tr>
            <xsl:for-each select="Solarsystem/Planets/Planet">
              <xsl:if test="@distfromsun &lt; 1">
              <tr>
                <td>
                  <xsl:value-of select="Name[@lang='eng']"/>
                </td>
                <td>
                  <xsl:value-of select="@distfromsun"/>
                </td>
                <td>
                  <xsl:value-of select="Atmosphere/@surfpress"/>
                </td>
                <td>
                  <ul>
                    <xsl:for-each select="Atmosphere/Component">
                      <li>
                        <xsl:value-of select="Name[@lang='eng']"/>
                        (
                        <xsl:for-each select="ChemElem">
                          <xsl:value-of select="."/>
                          <xsl:if test="@atoms &gt; 1">
                            <sub>
                              <xsl:value-of select="@atoms"/>
                            </sub>
                          </xsl:if>
                        </xsl:for-each>
                        )
                        - [<xsl:value-of select="@percent"/>%]
                      </li>

                    </xsl:for-each>
                  </ul>
                </td>
                <td>
                  <xsl:element name="a">
                    <xsl:attribute name="href">
                      <xsl:value-of select="MoreInfo"/>
                    </xsl:attribute>
                    <xsl:value-of select="MoreInfo"/>
                  </xsl:element>
                </td>
              </tr>
              </xsl:if>
            </xsl:for-each>
          </table>
        </body>
      </html>
  </xsl:template>
</xsl:stylesheet>

XSLT sorteeritud tabeli genereerimiseks

<?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>
        <style type="text/css">
          table, td, th { border: 1px solid gray }
          td {align:center;}
        </style>
        <title>Sort by weight</title>
      </head>

      <body>
        <table>
          <tr>
            <th>Planeedi nimi</th>
            <th>Planeedi mass(Earth masses)</th>
            <th>Kaugus päikesest(AU)</th>
          </tr>
          <xsl:for-each select="Solarsystem/Planets/Planet">
            <xsl:sort select="@mass" order="descending" data-type="number"/>
            <tr>
              <td>
                <xsl:value-of select="Name"/>
              </td>
              <td>
                <xsl:value-of select="@mass"/>
              </td>

              <td>
                <xsl:value-of select="@distfromsun"/>
              </td>

            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Planeetide ja nende infolinkide XML-i produtseermise XSLT

<?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" omit-xml-declaration="yes" cdata-section-elements="Name Link"/>
    <xsl:template match="/">
    <Solarsystem>
      <Planets>
        <xsl:for-each select="Solarsystem/Planets/Planet">
        <Planet>
          <Name>
            <xsl:value-of select="Name"/>
          </Name>
          <Link>
            <xsl:value-of select="MoreInfo"/>
          </Link>
        </Planet>
          </xsl:for-each>
      </Planets>
      </Solarsystem>
  </xsl:template>
</xsl:stylesheet>

Retsensioon

Retsensioon meeskonnale HMR meeskonnalt /*Anonüümsed koodikommentaatorid*/ asub meeskonnale HMR siin

Veebiteenus

Klientrakendus

Logi

25.02.15 - esimene projektimeeskonna käraja

06.03.15 - XML kodutöö esitamine

xml ja esialgne xslt on olemas. xsd ja üht-teist veel tuleb lähiajal.

07.03.15 - XML kodutöö esitamine

Kogu kompott peaks olema siis nüüd üles laetud