Givela

From ICO wiki
Revision as of 13:35, 16 March 2016 by Vrokovan (talk | contribs) (→‎XSLT)
Jump to navigationJump to search

Kodutöö aines "Võrgurakendused II: hajussüsteemide ehitamine"

Meeskond

  • Mikk Raudsepp
  • Alar Ameerikas
  • Vladimir Rõkovanov

Idee

XML/XSD/XSLT

XML

<?xml version="1.0" encoding="utf-8" ?>
<Products>
  <Persons>
    <Person><![CDATA[Mikk]]></Person>
    <Person><![CDATA[Alar]]></Person>
    <Person><![CDATA[Vladimir]]></Person>
  </Persons>
  <Categories>
    <Category><![CDATA[Riided]]></Category>
    <Category><![CDATA[Köögitehnika]]></Category>
  </Categories>
  <Product>
    <Name><![CDATA[Siidisukad 160]]></Name>
    <Person><![CDATA[Mikk]]></Person>
    <Category><![CDATA[Riided]]></Category>
    <ImageUrl>http://enos.itcollege.ee/~vrokovan/haju/sukad.jpg</ImageUrl>
    <Comments>
      <Comment><![CDATA[Kus asute?]]></Comment>
      <Comment><![CDATA[Kas on uued või kasutatud]]></Comment>
    </Comments>
  </Product>
  <Product>
    <Name><![CDATA[Külmkapp]]></Name>
    <Person><![CDATA[Alar]]></Person>
    <Category><![CDATA[Köögitehnika]]></Category>
    <ImageUrl>http://enos.itcollege.ee/~vrokovan/haju/kylmik.jpg</ImageUrl>
    <Comments>
      <Comment><![CDATA[Saatke mõõdud palun]]></Comment>
      <Comment><![CDATA[kui vana külmkapp on?]]></Comment>
    </Comments>
  </Product>
  <Product>
    <Name><![CDATA[Veekeetja]]></Name>
    <Person><![CDATA[Vladimir]]></Person>
    <Category><![CDATA[Köögitehnika]]></Category>
    <ImageUrl>http://enos.itcollege.ee/~vrokovan/haju/keetja.jpg</ImageUrl>
    <Comments>
      <Comment><![CDATA[Kas on töökorras?]]></Comment>
      <Comment><![CDATA[mitme liitrine on?]]></Comment>
    </Comments>
  </Product>
</Products>

<?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

 <xs:element name="Products">
   <xs:complexType>
     <xs:sequence>
       <xs:element name="Persons">
         <xs:complexType>
           <xs:sequence>
             <xs:element maxOccurs="unbounded" name="Person" type="xs:string" />
           </xs:sequence>
         </xs:complexType>
       </xs:element>
       <xs:element name="Categories">
         <xs:complexType>
           <xs:sequence>
             <xs:element maxOccurs="unbounded" name="Category" type="xs:string" />
           </xs:sequence>
         </xs:complexType>
       </xs:element>
       <xs:element maxOccurs="unbounded" name="Product">
         <xs:complexType>
           <xs:sequence>
             <xs:element name="Name" type="xs:string" />
             <xs:element name="Person" type="xs:string" />
             <xs:element name="Category" type="xs:string" />
             <xs:element name="ImageUrl" type="xs:string" />
             <xs:element name="Comments">
               <xs:complexType>
                 <xs:sequence>
                   <xs:element maxOccurs="unbounded" name="Comment" type="xs:string" />
                 </xs:sequence>
               </xs:complexType>
             </xs:element>
           </xs:sequence>
         </xs:complexType>
       </xs:element>
     </xs:sequence>
   </xs:complexType>
 </xs:element>

</xs:schema>

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="html" indent="yes"/>

    <xsl:template match="/">
      <html>
        <head>
         
          <title>Tooted</title>
          <!-- Essential CSS Files -->
          <link rel="stylesheet" href="http://enos.itcollege.ee/~vrokovan/bootstrap/css/bootstrap.min.css"/>
          
        </head>
        <body>
          <div class="container">
            <xsl:for-each select="/Products/Categories/Category">
              <xsl:variable name="MainCategory" select="."></xsl:variable>
              <!--
              <li>
                <xsl:value-of select="."/>
              </li>-->
              <h2>
                <xsl:value-of select="$MainCategory"/>
              </h2>
              <ul>
                <xsl:for-each select="/Products/Product">

                  <xsl:variable select="." name="Product"></xsl:variable>
                  <xsl:if test="Category = $MainCategory">
                    <li>
                      <p>
                        <xsl:value-of select="$Product/Name"/>

                        Kasutaja: <xsl:value-of select="$Product/Person"/>
                      </p>
                      <img width="100px">
                        <xsl:attribute name="src"  >
                          <xsl:value-of select="$Product/ImageUrl"/>
                        </xsl:attribute>
                      </img>

                      <!--
                    <img src="{$Movie/ImageUrl/.}" width="100" height="100" />
                    -->
                    </li>

                    <ul>
                      <xsl:for-each select="Comments/Comment">
                        <li>
                          <xsl:value-of select="."/>
                        </li>
                      </xsl:for-each>
                    </ul>
                  </xsl:if>
                </xsl:for-each>
              </ul>
            </xsl:for-each>
          </div>
        </body>
      </html>
    </xsl:template>
</xsl:stylesheet>

Logi

  1. 09.03.16 - Esimene kohtumine