Savi: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Line 509: | Line 509: | ||
</xsl:for-each> | </xsl:for-each> | ||
</xsl:template> | </xsl:template> | ||
</xsl:stylesheet> | |||
</pre> | |||
Näitab menüüst teisi toite va pitsad | |||
<pre> | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |||
<xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes" /> | |||
<xsl:template match="/"> | |||
<xsl:text disable-output-escaping="yes"><!DOCTYPE html> | |||
</xsl:text> | |||
<html> | |||
<head> | |||
<meta charset="UTF-8"/> | |||
<title>Menüü</title> | |||
</head> | |||
<body> | |||
<h2>Menüü</h2> | |||
<xsl:for-each select="Menu/Category[@name='Salad']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Small</th> | |||
<th>Large</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<xsl:for-each select="Size/*"> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</xsl:for-each> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
<xsl:for-each select="Menu/Category[@name='Spaghetti']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Price</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
<xsl:for-each select="Menu/Category[@name='Ziti']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Price</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
<xsl:for-each select="Menu/Category[@name='Lasagna']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Price</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
<xsl:for-each select="Menu/Category[@name='Ravioli']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Price</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
<xsl:for-each select="Menu/Category[@name='Manicotti']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Price</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
<xsl:for-each select="Menu/Category[@name='Calzone']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Price</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<xsl:for-each select="Size/*"> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</xsl:for-each> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
<xsl:for-each select="Menu/Category[@name='Wrap']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Price</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
<xsl:for-each select="Menu/Category[@name='Grinder']"> | |||
<table border="1"> | |||
<tr> | |||
<th> | |||
<xsl:value-of select="@name"/> | |||
</th> | |||
<th>Small</th> | |||
<th>Large</th> | |||
</tr> | |||
<xsl:for-each select="*"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="@name"/> | |||
</td> | |||
<xsl:for-each select="Size/*"> | |||
<td> | |||
<xsl:value-of select="Price"/> | |||
</td> | |||
</xsl:for-each> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</xsl:for-each> | |||
</body> | |||
</html> | |||
</xsl:template> | |||
</xsl:stylesheet> | </xsl:stylesheet> | ||
</pre> | </pre> |
Revision as of 12:49, 6 March 2015
Savi
Meeskonna liikmed
- Tõnu Sein
- Arvi Kangas
- Andres Sööt
- Marek Öövel
- Marju Niinemaa
XML andmefail
XML fail
<?xml version="1.0" encoding="UTF-8"?> <!--Fastfood restorant Menu--> <Menu> <Category name="Pizza"> <Menu_Item name="Tomato & Cheese"> <Crust> <Size> <Small> <Price>5.50</Price> </Small> <Large> <Price>9.75</Price> </Large> <Extra_Large> <Price>12.30</Price> </Extra_Large> </Size> </Crust> <Pan> <Size> <Small> <Price>7.50</Price> </Small> <Large> <Price>10.75</Price> </Large> <Extra_Large> <Price>14.30</Price> </Extra_Large> </Size> </Pan> </Menu_Item> <Menu_Item name="Onion"> <Crust> <Size> <Small> <Price>6.85</Price> </Small> <Large> <Price>10.85</Price> </Large> <Extra_Large> <Price>15.30</Price> </Extra_Large> </Size> </Crust> <Pan> <Size> <Small> <Price>7.50</Price> </Small> <Large> <Price>12.75</Price> </Large> <Extra_Large> <Price>16.30</Price> </Extra_Large> </Size> </Pan> </Menu_Item> <Menu_Item name="Pepper"> <Crust> <Size> <Small> <Price>6.85</Price> </Small> <Large> <Price>10.85</Price> </Large> <Extra_Large> <Price>11.30</Price> </Extra_Large> </Size> </Crust> <Pan> <Size> <Small> <Price>8.85</Price> </Small> <Large> <Price>14.85</Price> </Large> <Extra_Large> <Price>18.30</Price> </Extra_Large> </Size> </Pan> </Menu_Item> </Category> <Category name="Specialty Pizza"> <Menu_Item name="Three Aces Special"> <Crust> <Size> <Small> <Price>9.80</Price> </Small> <Large> <Price>15.80</Price> </Large> <Extra_Large> <Price>20.30</Price> </Extra_Large> </Size> </Crust> <Pan> <Size> <Small> <Price>2.80</Price> </Small> <Large> <Price>18.80</Price> </Large> <Extra_Large> <Price>25.30</Price> </Extra_Large> </Size> </Pan> </Menu_Item> <Menu_Item name="Mediterranean"> <Crust> <Size> <Small> <Price>9.80</Price> </Small> <Large> <Price>15.80</Price> </Large> <Extra_Large> <Price>20.30</Price> </Extra_Large> </Size> </Crust> <Pan> <Size> <Small> <Price>10.80</Price> </Small> <Large> <Price>18.80</Price> </Large> <Extra_Large> <Price>25.30</Price> </Extra_Large> </Size> </Pan> </Menu_Item> <Menu_Item name="Vegetarian"> <Crust> <Size> <Small> <Price>9.80</Price> </Small> <Large> <Price>15.80</Price> </Large> <Extra_Large> <Price>11.30</Price> </Extra_Large> </Size> </Crust> <Pan> <Size> <Small> <Price>9.80</Price> </Small> <Large> <Price>15.80</Price> </Large> <Extra_Large> <Price>11.30</Price> </Extra_Large> </Size> </Pan> </Menu_Item> </Category> <Category name="Special Dinner"> <Menu_Item name="Chicken Wing Dinner"> <Price>7.25</Price> </Menu_Item> <Menu_Item name="Gyro Plate"> <Price>7.25</Price> </Menu_Item> <Menu_Item name="Chicken Kabob Plate"> <Price>7.85</Price> </Menu_Item> </Category> <Category name="Side Order"> <Menu_Item name="Onion Rings"> <Size> <Small> <Price>2.60</Price> </Small> <Large> <Price>2.95</Price> </Large> </Size> </Menu_Item> <Menu_Item name="French Fries"> <Size> <Small> <Price>2.25</Price> </Small> <Large> <Price>2.65</Price> </Large> </Size> </Menu_Item> <Menu_Item name="Spicy Fries"> <Size> <Small> <Price>2.60</Price> </Small> <Large> <Price>2.95</Price> </Large> </Size> </Menu_Item> </Category> <Category name="Salad"> <Menu_Item name="Garden"> <Size> <Small> <Price>3.50</Price> </Small> <Large> <Price>4.50</Price> </Large> </Size> </Menu_Item> <Menu_Item name="Greek"> <Size> <Small> <Price>4.50</Price> </Small> <Large> <Price>5.50</Price> </Large> </Size> </Menu_Item> <Menu_Item name="Kabob Salad"> <Size> <Small> <Price>5.45</Price> </Small> <Large> <Price>6.45</Price> </Large> </Size> </Menu_Item> </Category> <Category name="Spaghetti"> <Menu_Item name="With Sauce"> <Price>5.40</Price> </Menu_Item> <Menu_Item name="With Sausage"> <Price>6.45</Price> </Menu_Item> <Menu_Item name="A la Three Aces"> <Price>7.25</Price> </Menu_Item> </Category> <Category name="Ziti"> <Menu_Item name="With Meat Ball"> <Price>6.45</Price> </Menu_Item> <Menu_Item name="With Veal"> <Price>6.45</Price> </Menu_Item> <Menu_Item name="Eggplant Ziti Dinner"> <Price>7.25</Price> </Menu_Item> </Category> <Category name="Lasagna"> <Menu_Item name="With Sauce"> <Price>6.25</Price> </Menu_Item> <Menu_Item name="With Sausage"> <Price>7.25</Price> </Menu_Item> <Menu_Item name="Veggie"> <Price>7.25</Price> </Menu_Item> </Category> <Category name="Ravioli"> <Menu_Item name="With Sauce"> <Price>6.25</Price> </Menu_Item> <Menu_Item name="With Sausage"> <Price>7.25</Price> </Menu_Item> <Menu_Item name="With Meatball"> <Price>7.25</Price> </Menu_Item> </Category> <Category name="Manicotti"> <Menu_Item name="With Sauce"> <Price>6.25</Price> </Menu_Item> <Menu_Item name="With Sausage"> <Price>7.25</Price> </Menu_Item> <Menu_Item name="With Meatball"> <Price>7.25</Price> </Menu_Item> </Category> <Category name="Calzone"> <Menu_Item name="Vegetarian"> <Size> <Large> <Price>7.35</Price> </Large> </Size> </Menu_Item> <Menu_Item name="Sausage"> <Size> <Large> <Price>7.35</Price> </Large> </Size> </Menu_Item> <Menu_Item name="Grecian"> <Size> <Large> <Price>7.35</Price> </Large> </Size> </Menu_Item> </Category> <Category name="Wrap"> <Menu_Item name="Turkey Club Wrap"> <Price>4.95</Price> </Menu_Item> <Menu_Item name="Chicken Cobb"> <Price>4.95</Price> </Menu_Item> <Menu_Item name="Greek Supreme"> <Price>4.95</Price> </Menu_Item> </Category> <Category name="Grinder"> <Menu_Item name="Meatless"> <Size> <Small> <Price>4.50</Price> </Small> <Large> <Price>4.95</Price> </Large> </Size> </Menu_Item> <Menu_Item name="Hamburger"> <Size> <Small> <Price>4.50</Price> </Small> <Large> <Price>4.95</Price> </Large> </Size> </Menu_Item> <Menu_Item name="Three Aces Special"> <Size> <Small> <Price>5.30</Price> </Small> <Large> <Price>6.40</Price> </Large> </Size> </Menu_Item> </Category> </Menu>
XML skeemifail
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- Help types --> <xs:simpleType name="priceType"> <xs:restriction base="xs:decimal"> <xs:minInclusive value="0"/> <xs:fractionDigits value="2"/> </xs:restriction> </xs:simpleType> <xs:complexType name="sizeType"> <xs:choice minOccurs="1" maxOccurs="unbounded"> <xs:element name="Small"> <xs:complexType> <xs:all> <xs:element name="Price" type="priceType"> </xs:element> </xs:all> </xs:complexType> </xs:element> <xs:element name="Large"> <xs:complexType> <xs:all> <xs:element name="Price" type="priceType"> </xs:element> </xs:all> </xs:complexType> </xs:element> <xs:element name="Extra_Large"> <xs:complexType> <xs:all> <xs:element name="Price" type="priceType"> </xs:element> </xs:all> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> <xs:element name="Menu"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element name="Category"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element name="Menu_Item"> <xs:complexType> <xs:choice minOccurs="1" maxOccurs="unbounded"> <xs:element name="Crust"> <xs:complexType> <xs:all> <xs:element name="Size" type="sizeType"/> </xs:all> </xs:complexType> </xs:element> <xs:element name="Pan"> <xs:complexType> <xs:all> <xs:element name="Size" type="sizeType"/> </xs:all> </xs:complexType> </xs:element> <xs:element name="Size" type="sizeType"/> <xs:element name="Price" type="priceType"/> </xs:choice> <xs:attribute name="name" type="xs:string"/> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="name" type="xs:string"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
XSLT fail
Näitab xml-i pitsade andmeid tabelis
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <xsl:for-each select="Menu/Category"> <h1></h1> <table> <caption><xsl:value-of select="@name"/></caption> <tr> <th>Pizza</th> <th colspan="3">Crust</th> <th colspan="3">Pan</th> </tr> <tr> <th></th> <th>Small</th> <th>Large</th> <th>Extra Large</th> <th>Small</th> <th>Large</th> <th>Extra Large</th> </tr> <xsl:for-each select="*"> <tr> <td><xsl:value-of select="@name"/></td> <xsl:for-each select="Crust/Size/*"> <td><xsl:value-of select="Price"></xsl:value-of></td> </xsl:for-each> <xsl:for-each select="Pan/Size/*"> <td><xsl:value-of select="Price"></xsl:value-of></td> </xsl:for-each> </tr> </xsl:for-each> </table> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Näitab menüüst teisi toite va pitsad
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> <xsl:text disable-output-escaping="yes"><!DOCTYPE html> </xsl:text> <html> <head> <meta charset="UTF-8"/> <title>Menüü</title> </head> <body> <h2>Menüü</h2> <xsl:for-each select="Menu/Category[@name='Salad']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Small</th> <th>Large</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <xsl:for-each select="Size/*"> <td> <xsl:value-of select="Price"/> </td> </xsl:for-each> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:for-each select="Menu/Category[@name='Spaghetti']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Price</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <td> <xsl:value-of select="Price"/> </td> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:for-each select="Menu/Category[@name='Ziti']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Price</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <td> <xsl:value-of select="Price"/> </td> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:for-each select="Menu/Category[@name='Lasagna']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Price</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <td> <xsl:value-of select="Price"/> </td> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:for-each select="Menu/Category[@name='Ravioli']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Price</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <td> <xsl:value-of select="Price"/> </td> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:for-each select="Menu/Category[@name='Manicotti']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Price</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <td> <xsl:value-of select="Price"/> </td> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:for-each select="Menu/Category[@name='Calzone']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Price</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <xsl:for-each select="Size/*"> <td> <xsl:value-of select="Price"/> </td> </xsl:for-each> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:for-each select="Menu/Category[@name='Wrap']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Price</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <td> <xsl:value-of select="Price"/> </td> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:for-each select="Menu/Category[@name='Grinder']"> <table border="1"> <tr> <th> <xsl:value-of select="@name"/> </th> <th>Small</th> <th>Large</th> </tr> <xsl:for-each select="*"> <tr> <td> <xsl:value-of select="@name"/> </td> <xsl:for-each select="Size/*"> <td> <xsl:value-of select="Price"/> </td> </xsl:for-each> </tr> </xsl:for-each> </table> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>