Lingviinid: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Line 196: | Line 196: | ||
===XSL 2=== | ===XSL 2=== | ||
<pre> | |||
<?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>Ilusalongi pakkumised</title> | |||
<style> | |||
table {width: 300px; | |||
border: 1px dotted black;} | |||
table tr {height: 30px;} | |||
h2 {color: blue;} | |||
.bold {font-weight: bold;} | |||
ul {list-style-type: none; | |||
padding: 0px; | |||
margin: 0px;} | |||
</style> | |||
</head> | |||
<body> | |||
<h2>Tooted</h2> | |||
<xsl:for-each select="Salon/Division"> | |||
<xsl:if test="@id = 1"> | |||
<xsl:for-each select="Item"> | |||
<table > | |||
<tr> | |||
<td colspan="2" class="bold"><xsl:value-of select="Name"></xsl:value-of><br /></td> | |||
</tr> | |||
<tr> | |||
<td>Kogus: <xsl:value-of select="concat(Amount, ' ', Amount/@unit)"/></td> | |||
<td>Laos: | |||
<xsl:choose> | |||
<xsl:when test="Stock>0"> | |||
On | |||
</xsl:when> | |||
<xsl:otherwise>Ei ole</xsl:otherwise> | |||
</xsl:choose> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td colspan="2"> | |||
<xsl:value-of select="Description"></xsl:value-of> | |||
</td> | |||
</tr> | |||
</table> | |||
<br/> | |||
</xsl:for-each> | |||
</xsl:if> | |||
</xsl:for-each> | |||
<h2>Teenused</h2> | |||
<xsl:for-each select="Salon/Division"> | |||
<xsl:if test="@id = 2"> | |||
<xsl:for-each select="Item"> | |||
<table> | |||
<tr> | |||
<td colspan="2" class="bold"><xsl:value-of select="Name"></xsl:value-of><br /></td> | |||
</tr> | |||
<tr> | |||
<td>Läbiviijad: | |||
<ul> | |||
<xsl:for-each select="Employees/Employee"> | |||
<li> | |||
<xsl:value-of select="."/> | |||
</li> | |||
</xsl:for-each> | |||
</ul> | |||
</td> | |||
<td> | |||
Kestvus: <xsl:value-of select="concat(Duration, ' ', Duration/@unit)"/> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td colspan="2"> | |||
<xsl:value-of select="Description"></xsl:value-of> | |||
</td> | |||
</tr> | |||
</table> | |||
<br/> | |||
</xsl:for-each> | |||
</xsl:if> | |||
</xsl:for-each> | |||
</body> | |||
</html> | |||
</xsl:template> | |||
</xsl:stylesheet> | |||
</pre> |
Revision as of 16:28, 8 March 2014
Kodutöö aines "Võrgurakendused II: hajussüsteemide ehitamine"
Meeskond
- Olga Trikk
- Johanna Kammiste
- Triin Oja
- Karin Lepik
XML
XML fail näidisandmetega
<?xml version="1.0" encoding="utf-8" ?> <Salon> <Division id="1" name="products"> <Item id="1" type="oil"> <Name><![CDATA[Massaažiõli]]></Name> <Description><![CDATA[Sobib suurepäraselt massaažide läbiviimiseks.]]></Description> <Amount unit="ml">200</Amount> <Price currency="eur">10.00</Price> <Stock>3</Stock> </Item> <Item id="2" type="oil"> <Name><![CDATA[Kehaõli]]></Name> <Description><![CDATA[Sobib igapäevaseks kasutamiseks.]]></Description> <Amount unit="ml">200</Amount> <Price currency="eur">7.00</Price> <Stock>0</Stock> </Item> <Item id="3" type="cream"> <Name><![CDATA[Näokreem]]></Name> <Description><![CDATA[Sobib igapäevaseks kasutamiseks.]]></Description> <Amount unit="ml">200</Amount> <Price currency="eur">8.00</Price> <Stock>3</Stock> </Item> <Item id="4" type="cream"> <Name><![CDATA[Kätekreem]]></Name> <Description><![CDATA[Teeb käed siidiselt pehmeks.]]></Description> <Amount unit="ml">100</Amount> <Price currency="eur">5.00</Price> <Stock>2</Stock> </Item> </Division> <Division id="2" name="services"> <Item id="1" type="massage"> <Name><![CDATA[Spordimassaaž]]></Name> <Description><![CDATA[Sobib hästi lihaste lõdvestamiseks peale tugevat sportimist.]]></Description> <Duration unit="min">45</Duration> <Price currency="eur">18.00</Price> <Employees> <Employee>Juta Juurikas</Employee> </Employees> </Item> <Item id="2" type="massage"> <Name><![CDATA[Seljamassaaž]]></Name> <Description><![CDATA[Põhjalik massaaž seljapiirkonnale. Sobib tööpingetest vabastamiseks.]]></Description> <Duration unit="h">1</Duration> <Price currency="eur">40.00</Price> <Employees> <Employee>Juta Juurikas</Employee> <Employee>Malle Maasikas</Employee> </Employees> </Item> <Item id="3" type="nailjob"> <Name><![CDATA[Klassikaline maniküür]]></Name> <Description><![CDATA[Igapäevaseks.]]></Description> <Duration unit="min">45</Duration> <Price currency="eur">18.00</Price> <Employees> <Employee>Kairi Kaalikas</Employee> <Employee>Mari Mustikas</Employee> </Employees> </Item> <Item id="4" type="nailjob"> <Name><![CDATA[Kiirmaniküür]]></Name> <Description><![CDATA[Kiireteks aegadeks.]]></Description> <Duration unit="min">25</Duration> <Price currency="eur">12.00</Price> <Employees> <Employee>Mari Mustikas</Employee> <Employee>Janne Joovikas</Employee> </Employees> </Item> <Item id="5" type="nailjob"> <Name><![CDATA[Prantsuse maniküür]]></Name> <Description><![CDATA[Midagi erilist erilisemateks päevadeks.]]></Description> <Duration unit="h">1</Duration> <Price currency="eur">21.00</Price> <Employees> <Employee>Sille Sinikas</Employee> <Employee>Vika Vaarikas</Employee> </Employees> </Item> <Item id="6" type="nailjob"> <Name><![CDATA[Klassikaline pediküür]]></Name> <Description><![CDATA[Turgutab keha ja vaimu.]]></Description> <Duration unit="h">1.5</Duration> <Price currency="eur">28.00</Price> <Employees> <Employee>Vika Vaarikas</Employee> <Employee>Janne Joovikas</Employee> </Employees> </Item> </Division> </Salon>
XML skeemifail
XSL 1
<?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>Ilusalongi hinnakiri</title> <style> h2 { color: blue; } table, td, th { border: 3px groove ##990099; border-collapse: collapse; padding: 3px; text-align: left } </style> </head> <body> <h2>Toodete hinnakiri</h2> <table> <tr> <th>Toode</th> <th>Kogus</th> <th>Hind</th> </tr> <xsl:for-each select="Salon/Division"> <xsl:if test="@id = 1"> <xsl:for-each select="Item"> <tr> <td> <xsl:value-of select="Name"></xsl:value-of> </td> <td> <xsl:value-of select="concat(Amount, ' ', Amount/@unit)"></xsl:value-of> </td> <td> <xsl:value-of select="concat(Price, ' ', Price/@currency)"></xsl:value-of> </td> </tr> </xsl:for-each> </xsl:if> </xsl:for-each> </table> <h2>Teenuste hinnakiri</h2> <table> <tr> <th>Teenus</th> <th>Kestus</th> <th>Hind</th> </tr> <xsl:for-each select="Salon/Division"> <xsl:if test="@id = 2"> <xsl:for-each select="Item"> <tr> <td> <xsl:value-of select="Name"></xsl:value-of> </td> <td> <xsl:value-of select="concat(Duration, ' ', Duration/@unit)"></xsl:value-of> </td> <td> <xsl:value-of select="concat(Price, ' ', Price/@currency)"></xsl:value-of> </td> </tr> </xsl:for-each> </xsl:if> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
XSL 2
<?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>Ilusalongi pakkumised</title> <style> table {width: 300px; border: 1px dotted black;} table tr {height: 30px;} h2 {color: blue;} .bold {font-weight: bold;} ul {list-style-type: none; padding: 0px; margin: 0px;} </style> </head> <body> <h2>Tooted</h2> <xsl:for-each select="Salon/Division"> <xsl:if test="@id = 1"> <xsl:for-each select="Item"> <table > <tr> <td colspan="2" class="bold"><xsl:value-of select="Name"></xsl:value-of><br /></td> </tr> <tr> <td>Kogus: <xsl:value-of select="concat(Amount, ' ', Amount/@unit)"/></td> <td>Laos: <xsl:choose> <xsl:when test="Stock>0"> On </xsl:when> <xsl:otherwise>Ei ole</xsl:otherwise> </xsl:choose> </td> </tr> <tr> <td colspan="2"> <xsl:value-of select="Description"></xsl:value-of> </td> </tr> </table> <br/> </xsl:for-each> </xsl:if> </xsl:for-each> <h2>Teenused</h2> <xsl:for-each select="Salon/Division"> <xsl:if test="@id = 2"> <xsl:for-each select="Item"> <table> <tr> <td colspan="2" class="bold"><xsl:value-of select="Name"></xsl:value-of><br /></td> </tr> <tr> <td>Läbiviijad: <ul> <xsl:for-each select="Employees/Employee"> <li> <xsl:value-of select="."/> </li> </xsl:for-each> </ul> </td> <td> Kestvus: <xsl:value-of select="concat(Duration, ' ', Duration/@unit)"/> </td> </tr> <tr> <td colspan="2"> <xsl:value-of select="Description"></xsl:value-of> </td> </tr> </table> <br/> </xsl:for-each> </xsl:if> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>