-.-: Difference between revisions

From ICO wiki
Jump to navigationJump to search
No edit summary
Line 15: Line 15:
Lisaks tuleb kasutada 3-el dimensioonil attribuute, mis one enamat, kui lihtsalt ID.
Lisaks tuleb kasutada 3-el dimensioonil attribuute, mis one enamat, kui lihtsalt ID.


=== XML ===
<?xml version="1.0" encoding="utf-8"?>
<source lang="xml">
<?xml version="1.0" encoding="utf-8"?>
   <tooted>
   <tooted>
   <alkoholid tootjariik="Eesti">
   <alkoholid tootjariik="Eesti">
Line 26: Line 24:
       </jook>
       </jook>
       <jook nimetus="Viru Valge">
       <jook nimetus="Viru Valge">
         <hind yhik="€">11.35</hind>
         <hind yhik="€">8.99</hind>
         <kangus yhik="%">80</kangus>
         <kangus yhik="%">40</kangus>
       </jook>
       </jook>
     </alkohol>
     </alkohol>
     <alkohol tyyp="Õlu">
     <alkohol tyyp="Õlu">
       <jook nimetus="Saku Kuld">
       <jook nimetus="Saku Kuld">
         <kangus yhik="%">5</kangus>
         <kangus yhik="%">5.1</kangus>
         <hind yhik="€">1</hind>
         <hind yhik="€">1.09</hind>
      </jook>
    </alkohol>
    <alkohol tyyp="Õlu">
      <jook nimetus="Saku Pilsner">
        <kangus yhik="%">4.6</kangus>
        <hind yhik="€">0.77</hind>
       </jook>
       </jook>
     </alkohol>
     </alkohol>
Line 54: Line 58:
     <alkohol tyyp="Õlu">
     <alkohol tyyp="Õlu">
       <jook nimetus="Tuborg">
       <jook nimetus="Tuborg">
         <kangus yhik="%">5</kangus>
         <kangus yhik="%">4.7</kangus>
         <hind yhik="€">1</hind>
         <hind yhik="€">0.89</hind>
       </jook>
       </jook>
     </alkohol>
     </alkohol>
   </alkoholid>
   </alkoholid>
  </tooted>
  </tooted>
</source>


=== XML schema (XSD) ===
=== XML schema (XSD) ===

Revision as of 04:09, 3 March 2012

Meeskond

  • Erki Miilberg (projektijuht)
  • Kalev Vallsalu
  • Oliver Naaris
  • Margo Kuustik

Idee

XML fail

Ülesande täitmiseks tuleb luua XML fail andmete edastamiseks, selle XML faili skeemifail ning paar kolm sobivat XSL faili loodud XML failis olevate andmete transformeerimiseks HTML formaati ja XML faili formaadi muutmiseks. XML-il peab olema vähemalt 4 loogilist dimensiooni.

Lisaks tuleb kasutada 3-el dimensioonil attribuute, mis one enamat, kui lihtsalt ID.

<?xml version="1.0" encoding="utf-8"?>

 <tooted>
 <alkoholid tootjariik="Eesti">
   <alkohol tyyp="Viin">
     <jook nimetus="Saaremaa Vodka">
       <hind yhik="€">11.10</hind>
       <kangus yhik="%">80</kangus>
     </jook>
     <jook nimetus="Viru Valge">
       <hind yhik="€">8.99</hind>
       <kangus yhik="%">40</kangus>
     </jook>
   </alkohol>
   <alkohol tyyp="Õlu">
     <jook nimetus="Saku Kuld">
       <kangus yhik="%">5.1</kangus>
       <hind yhik="€">1.09</hind>
     </jook>
   </alkohol>
   <alkohol tyyp="Õlu">
     <jook nimetus="Saku Pilsner">
       <kangus yhik="%">4.6</kangus>
       <hind yhik="€">0.77</hind>
     </jook>
   </alkohol>
 </alkoholid>
 <alkoholid tootjariik="Iirimaa">
   <alkohol tyyp="Viski">
     <jook nimetus="Grant's">
       <kangus yhik="%">40</kangus>
       <hind yhik="€">58.25</hind>
     </jook>
   </alkohol>
 </alkoholid>
 <alkoholid tootjariik="Taani">
   <alkohol tyyp="Õlu">
     <jook nimetus="Carlsberg">
       <kangus yhik="%">5</kangus>
       <hind yhik="€">1</hind>
     </jook>
   </alkohol>
   <alkohol tyyp="Õlu">
     <jook nimetus="Tuborg">
       <kangus yhik="%">4.7</kangus>
       <hind yhik="€">0.89</hind>
     </jook>
   </alkohol>
 </alkoholid>
</tooted>

XML schema (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="tooted">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="alkoholid">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="alkohol">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="jook">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:choice maxOccurs="unbounded">
                            <xs:element name="hind">
                              <xs:complexType>
                                <xs:simpleContent>
                                  <xs:extension base="xs:decimal">
                                    <xs:attribute name="yhik" type="xs:string" use="required" />
                                  </xs:extension>
                                </xs:simpleContent>
                              </xs:complexType>
                            </xs:element>
                            <xs:element name="kangus">
                              <xs:complexType>
                                <xs:simpleContent>
                                  <xs:extension base="xs:unsignedByte">
                                    <xs:attribute name="yhik" type="xs:string" use="required" />
                                  </xs:extension>
                                </xs:simpleContent>
                              </xs:complexType>
                            </xs:element>
                          </xs:choice>
                        </xs:sequence>
                        <xs:attribute name="nimetus" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="tyyp" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="tootjariik" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="/">
  <html>
  <body>
    <table>
      <tr>
	<th>tüüp</th>
	<th>nimetus</th>
        <th>kangus</th>
        <th>hind</th>
      </tr>
      <xsl:for-each select="tooted/alkoholid/alkohol">
	  <xsl:sort select="jook/kangus" data-type="number" order="descending"/>
      <tr>
	<td><xsl:value-of select="@tyyp"/></td>
	<td><xsl:value-of select="jook/@nimetus"/></td>
        <td><xsl:value-of select="jook/kangus"/><xsl:value-of select="jook/kangus/@yhik"/></td>
        <td><xsl:value-of select="jook/hind"/><xsl:value-of select="jook/hind/@yhik"/></td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>