FreeVar: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Line 186: Line 186:


=== XSLT ===
=== XSLT ===
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
    xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; exclude-result-prefixes=&quot;msxsl&quot;
&gt;
  &lt;xsl:output method=&quot;html&quot; indent=&quot;yes&quot;/&gt;
  &lt;xsl:key name=&quot;companiesByType&quot; match=&quot;type&quot; use = &quot;current()&quot;/&gt;
  &lt;xsl:template match=&quot;/&quot;&gt;
    &lt;html&gt;
      &lt;body&gt;
        Ettev&#245;tted grupeeritud tegevusala j&#228;rgi:
        &lt;ul&gt;
          &lt;xsl:for-each select=&quot;/companies/company/type[generate-id(.) = generate-id(key(&#39;companiesByType&#39;, .)[1])]&quot;&gt;
            &lt;li&gt;
              &lt;h1&gt;
                &lt;xsl:value-of select=&quot;.&quot;/&gt;
              &lt;/h1&gt;
              &lt;xsl:variable name=&quot;typeVal&quot; select=&#39;.&#39; /&gt;
              &lt;ul&gt;
                &lt;xsl:for-each select=&quot;//companies/company[type = $typeVal]&quot;&gt;
                  &lt;li&gt;
                    &lt;h2&gt;
                      &lt;xsl:value-of select=&quot;name&quot;/&gt;
                    &lt;/h2&gt;
                    &lt;p&gt;Aadress: &lt;xsl:value-of select=&quot;address/street&quot;/&gt;, &lt;xsl:value-of select=&quot;address/postcode&quot;/&gt;, &lt;xsl:value-of select=&quot;address/country&quot;/&gt;&lt;/p&gt;
                    &lt;p&gt;Telefon:
                    &lt;xsl:choose&gt;
                      &lt;xsl:when test=&quot;not(address/phone)&quot;&gt;
                        &lt;xsl:text&gt;Salastatud&lt;/xsl:text&gt;
                      &lt;/xsl:when&gt;
                      &lt;xsl:when test=&quot;address/phone = &#39;&#39;&quot;&gt;
                        &lt;xsl:text&gt;Ei ole sisestatud&lt;/xsl:text&gt;
                      &lt;/xsl:when&gt;
                      &lt;xsl:otherwise&gt;
                        &lt;xsl:value-of select=&quot;address/phone&quot;/&gt;
                      &lt;/xsl:otherwise&gt;
                    &lt;/xsl:choose&gt;
                    &lt;/p&gt;
                   
                    &lt;h3&gt;T&#246;&#246;tajad&lt;/h3&gt;
                    &lt;ul&gt;
                      &lt;xsl:for-each select=&quot;employees/employee&quot;&gt;
                        &lt;li&gt;
                          &lt;xsl:value-of select=&quot;name&quot;/&gt; (Telefon: &lt;xsl:value-of select=&quot;phone&quot;/&gt;, t&#246;&#246;leping: &lt;xsl:value-of select=&quot;@contract&quot;/&gt;)
                        &lt;/li&gt;
                      &lt;/xsl:for-each&gt;
                    &lt;/ul&gt;
                  &lt;/li&gt;
                &lt;/xsl:for-each&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
          &lt;/xsl:for-each&gt;
        &lt;/ul&gt;
      &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
    xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; exclude-result-prefixes=&quot;msxsl&quot;
&gt;
  &lt;xsl:output method=&quot;html&quot; indent=&quot;yes&quot;/&gt;
  &lt;xsl:template match=&quot;/&quot;&gt;
    &lt;html&gt;
      &lt;body&gt;
        T&#246;&#246;tajate palgad:
        &lt;ul&gt;
          &lt;xsl:for-each select=&quot;//companies/company&quot;&gt;
         
            &lt;li&gt;
              &lt;xsl:value-of select=&quot;name&quot;/&gt;
              &lt;xsl:variable name=&quot;avgSalary&quot; select=&quot;round(sum(employees/employee/salary) div count(employees/employee))&quot;/&gt;
              (Keskmine t&#246;&#246;tasu:  &lt;xsl:value-of select=&quot;$avgSalary&quot;&gt;&lt;/xsl:value-of&gt;)
              &lt;ul&gt;
                &lt;xsl:for-each select=&quot;employees/employee&quot;&gt;
                  &lt;li&gt;
                    &lt;xsl:variable name=&quot;employeeSalary&quot; select=&quot;salary&quot;&gt;&lt;/xsl:variable&gt;
                    &lt;xsl:variable name=&quot;comparedToCompanyAvg&quot; select=&quot;$avgSalary - $employeeSalary&quot;&gt;&lt;/xsl:variable&gt;
                    &lt;xsl:value-of select=&quot;name&quot;/&gt;
                    (T&#246;&#246;tasu kuus: &lt;xsl:value-of select=&quot;salary&quot;/&gt;,
                    teenib keskmisest: &lt;xsl:value-of select=&quot;translate($comparedToCompanyAvg, &#39;-&#39;, &#39;&#39;)&quot;/&gt;
                    &lt;xsl:choose&gt;
                      &lt;xsl:when test=&quot;$comparedToCompanyAvg &gt; 0&quot;&gt;
                        v&#228;hem
                      &lt;/xsl:when&gt;
                      &lt;xsl:otherwise&gt;
                        rohkem
                      &lt;/xsl:otherwise&gt;
                    &lt;/xsl:choose&gt;
                    )
                  &lt;/li&gt;
                &lt;/xsl:for-each&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
           
          &lt;/xsl:for-each&gt;
        &lt;/ul&gt;
      &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>

Revision as of 20:48, 13 March 2016

Tiim

  • Mihkel Viilveer
  • Kristjan Adrat

Blogi

  • 08.03 - Tiimi loomine.
  • 12.03 - Wiki skeleton. VSO projekti ja GIT repo loomine.

Idee

Kasutusele võetavad tehnoloogiad

Analüüs

QSEE andmebaasiskeem

Rakenduse sisu

Rakenduses Must have võimalused:

Rakenduse Nice to have lisavõimalused:

XML osa

XML Fail

<?xml version="1.0" encoding="UTF-8"?>
<companies>
 <company id="1">
  <name>Schmidt PLC</name>
  <workerCount>9</workerCount>
  <type>Information</type>
  <address>
   <street>8181 Volkman Place</street>
   <city>West Dewayne</city>
   <postcode>30030-1343</postcode>
   <country>Jersey</country>
   <phone></phone>
  </address>
  <employees>
   <employee contract="full-time" occupation="Compacting Machine Operator">
    <name>Rogers Kutch Sr.</name>
    <phone>802-112-0733</phone>
    <salary>1152</salary>
   </employee>
   <employee contract="full-time" occupation="Electrical Engineer">
    <name>Chelsea Turcotte DDS</name>
    <phone>818.181.9337x490</phone>
    <salary>3412</salary>
   </employee>
   <employee contract="full-time" occupation="Producer">
    <name>Rey Altenwerth PhD</name>
    <phone>855.153.8231x79547</phone>
    <salary>3672</salary>
   </employee>
   <employee contract="full-time" occupation="Animal Control Worker">
    <name>Maryse Schmidt</name>
    <phone>09527107290</phone>
    <salary>3539</salary>
   </employee>
   <employee contract="part-time" occupation="Educational Counselor OR Vocationall Counselor">
    <name>Josie Baumbach</name>
    <phone>07180334208</phone>
    <salary>3019</salary>
   </employee>
   <employee contract="part-time" occupation="Fashion Model">
    <name>Kareem Graham</name>
    <phone>425.306.3170</phone>
    <salary>3811</salary>
   </employee>
   <employee contract="part-time" occupation="Webmaster">
    <name>Michaela Weissnat</name>
    <phone>1-688-533-3918x2902</phone>
    <salary>1124</salary>
   </employee>
   <employee contract="full-time" occupation="Nonfarm Animal Caretaker">
    <name>Dr. Toney Hamill</name>
    <phone>1-626-583-8931</phone>
    <salary>2888</salary>
   </employee>
   <employee contract="full-time" occupation="Singer">
    <name>Soledad Hansen</name>
    <phone>031.695.7461x523</phone>
    <salary>2087</salary>
   </employee>
  </employees>
 </company>
 <company id="2">
  <name>Langworth, Conroy and Bauch</name>
  <workerCount>7</workerCount>
  <type>Arts, Entertainment, and Recreation</type>
  <address>
   <street>615 Gorczany Rapids</street>
   <city>West Hyman</city>
   <postcode>72688</postcode>
   <country>Angola</country>
   <phone>04554658252</phone>
  </address>
  <employees>
   <employee contract="full-time" occupation="Computer Security Specialist">
    <name>Tyrese Auer</name>
    <phone>(238)773-9387x4752</phone>
    <salary>1063</salary>
   </employee>
   <employee contract="full-time" occupation="Railroad Yard Worker">
    <name>Ms. Danielle Russel Jr.</name>
    <phone>+73(2)2183429933</phone>
    <salary>3038</salary>
   </employee>
   <employee contract="full-time" occupation="Steel Worker">
    <name>Mrs. Elza Koch I</name>
    <phone>(384)024-0108</phone>
    <salary>2709</salary>
   </employee>
   <employee contract="part-time" occupation="Petroleum Pump System Operator">
    <name>Jermaine Hegmann</name>
    <phone>427.168.3059x031</phone>
    <salary>2729</salary>
   </employee>
   <employee contract="full-time" occupation="Human Resources Assistant">
    <name>Ms. Sydni Marquardt</name>
    <phone>701.387.7215x03428</phone>
    <salary>1747</salary>
   </employee>
   <employee contract="full-time" occupation="Optometrist">
    <name>Miss Rosella Swift DDS</name>
    <phone>737-209-4634x8495</phone>
    <salary>2708</salary>
   </employee>
   <employee contract="full-time" occupation="Correspondence Clerk">
    <name>Letitia Buckridge</name>
    <phone>526-083-7143x036</phone>
    <salary>3587</salary>
   </employee>
  </employees>
 </company>
 <company id="3">
  <name>Altenwerth, Zemlak and Mraz</name>
  <workerCount>6</workerCount>
  <type>Information</type>
  <address>
   <street>16060 Crystal Grove</street>
   <city>Rippinton</city>
   <postcode>16164-5194</postcode>
   <country>Swaziland</country>
   <phone>(966)924-6974</phone>
  </address>
  <employees>
   <employee contract="part-time" occupation="Milling Machine Operator">
    <name>Robb Gulgowski</name>
    <phone>08557661700</phone>
    <salary>3030</salary>
   </employee>
   <employee contract="part-time" occupation="Cartographer">
    <name>Dr. Adaline Reinger</name>
    <phone>1-004-556-1080x74960</phone>
    <salary>3876</salary>
   </employee>
   <employee contract="full-time" occupation="Carpenter Assembler and Repairer">
    <name>Velda Sanford</name>
    <phone>431.198.4270</phone>
    <salary>2913</salary>
   </employee>
   <employee contract="full-time" occupation="Government">
    <name>Garret Armstrong</name>
    <phone>702-909-3199</phone>
    <salary>1597</salary>
   </employee>
   <employee contract="part-time" occupation="Telephone Station Installer and Repairer">
    <name>Claire Predovic</name>
    <phone>007.971.7079x723</phone>
    <salary>2871</salary>
   </employee>
   <employee contract="full-time" occupation="Meter Mechanic">
    <name>Loyce Ebert</name>
    <phone>651-879-5115x1261</phone>
    <salary>2058</salary>
   </employee>
  </employees>
 </company>
</companies>

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:key name="companiesByType" match="type" use = "current()"/>
  <xsl:template match="/">
    <html>
      <body>
        Ettevõtted grupeeritud tegevusala järgi:
        <ul>
          <xsl:for-each select="/companies/company/type[generate-id(.) = generate-id(key('companiesByType', .)[1])]">
            <li>
              <h1>
                <xsl:value-of select="."/>
              </h1>
              <xsl:variable name="typeVal" select='.' />
              <ul>
                <xsl:for-each select="//companies/company[type = $typeVal]">
                  <li>
                    <h2>
                      <xsl:value-of select="name"/>
                    </h2>
                    <p>Aadress: <xsl:value-of select="address/street"/>, <xsl:value-of select="address/postcode"/>, <xsl:value-of select="address/country"/></p>
                    <p>Telefon: 
                     <xsl:choose>
                      <xsl:when test="not(address/phone)">
                        <xsl:text>Salastatud</xsl:text>
                      </xsl:when>
                      <xsl:when test="address/phone = ''">
                        <xsl:text>Ei ole sisestatud</xsl:text>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:value-of select="address/phone"/>
                      </xsl:otherwise>
                    </xsl:choose>
                    </p>
                    
                    <h3>Töötajad</h3>
                    <ul>
                      <xsl:for-each select="employees/employee">
                        <li>
                          <xsl:value-of select="name"/> (Telefon: <xsl:value-of select="phone"/>, tööleping: <xsl:value-of select="@contract"/>)
                        </li>
                      </xsl:for-each>
                    </ul>
                  </li>
                </xsl:for-each>
              </ul>
            </li>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
<?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>
      <body>
        Töötajate palgad:
        <ul>
          <xsl:for-each select="//companies/company">
           
            <li>
              <xsl:value-of select="name"/>
              <xsl:variable name="avgSalary" select="round(sum(employees/employee/salary) div count(employees/employee))"/>
              (Keskmine töötasu:  <xsl:value-of select="$avgSalary"></xsl:value-of>)
              <ul>
                <xsl:for-each select="employees/employee">
                  <li>
                    <xsl:variable name="employeeSalary" select="salary"></xsl:variable>
                    <xsl:variable name="comparedToCompanyAvg" select="$avgSalary - $employeeSalary"></xsl:variable>

                    <xsl:value-of select="name"/> 
                    (Töötasu kuus: <xsl:value-of select="salary"/>, 
                    teenib keskmisest: <xsl:value-of select="translate($comparedToCompanyAvg, '-', '')"/>
                    <xsl:choose>
                      <xsl:when test="$comparedToCompanyAvg > 0">
                        vähem
                      </xsl:when>
                      <xsl:otherwise>
                        rohkem
                      </xsl:otherwise>
                    </xsl:choose>
                    )
                  </li>
                </xsl:for-each>
              </ul>
            </li>
            
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>