FreeVar
From ICO wiki
Tiim
- Mihkel Viilveer
- Kristjan Adrat
Blogi
- 08.03 - Tiimi loomine.
- 12.03 - Wiki skeleton. VSO projekti ja GIT repo loomine.
- 13.03 - Valmisid XML, XSD, XSLT failid
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>
XSD Fail
<?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="companies"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="company" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element name="workerCount" type="xs:unsignedInt" minOccurs="1" maxOccurs="1" /> <xs:element name="type" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element name="address" minOccurs="1" maxOccurs="1"> <xs:complexType> <xs:sequence> <xs:element name="street" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element name="city" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element name="postcode" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element name="country" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element minOccurs="0" name="phone" type="xs:string" maxOccurs="1"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="employees"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="employee" minOccurs="1"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element name="phone" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element name="salary" type="xs:unsignedInt" minOccurs="1" maxOccurs="1"/> </xs:sequence> <xs:attribute name="contract" type="xs:string" use="required" /> <xs:attribute name="occupation" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="id" type="xs:unsignedInt" use="required" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>