Hello all , I am using windows Vista & stylus 09, and saxon 9.1
I'm taking a course on xml at my uni and have gone through alot of material but am lacking in experience
The xml has root element "restaruantguide" and many "restaurant" children, each with random bits of data bout restaurant (cuisin, opening time,etc) i want to output a html file (with css) spitting out info about the restaurant sorted in different ways, the first is wether or not it has seasonal offers (seasonal is a child element of restaurant)
in my first template i match the root element and add all the html tages and the head and all the css required. i know it works but is it the best way to do so.
in my 2nd template:
<xsl:template match="RESTAURANT[SEASONAL]">
<tr><td>
<xsl:value-of select="NAME"/>
</td>
<td>
<xsl:value-of select="ACCEPTEDCARDS"/>
</td>
<td>
<xsl:value-of select="ADDRESS"/>
</td>
</tr>
</xsl:template>
from this i undestand that it will match restaurant elements that have the SEASONAL element which is 2/4 retaurants, but what happens is just after the table is started in the first template it spits out all information about all restaurants and then does the matching and adds it into the table.
Thanks for bearing with me with this and i thank you for reading
My XML=============================================== ==
<?xml version="1.0"?>
<!DOCTYPE RESTAURANTGUIDE SYSTEM "Ass2.dtd">
<?xml-stylesheet type="text/css" href="style.css"?>
<RESTAURANTGUIDE>
<RESTAURANT STATUS="SELECTED" BOOKONLINE="TRUE" CHILDRENWELCOME="TRUE" GROUPSALLOWED="TRUE" AIRCONDITIONING="TRUE" OUTSIDESEATING="FALSE" RESERVATIONS="TRUE" COVERCHARGE="FALSE">
<NAME>Roast</NAME>
<ADDRESS>
<STREETNUMBERORNAME>The Flora Hall, Borough Market</STREETNUMBERORNAME>
<STREETNAME>Stoney Street</STREETNAME>
<CITY>London</CITY>
<POSTCODE>SE1 1TL</POSTCODE>
<COUNTRY>United Kingdom</COUNTRY>
</ADDRESS>
<CUISINE>Modern British</CUISINE>
<AVGLUNCH>35</AVGLUNCH>
<AVGDINNER>55</AVGDINNER>
<CONTACT>
<TEL>+44(0)8445672354</TEL>
<EMAIL>
[email protected]</EMAIL>
<WEBSITE>http://www.roast-restaurant.com/</WEBSITE>
</CONTACT>
<OPENINGTIMES>
<MON-FRI>07:00 - 11:00,12:00 - 14:45, 15:30 - 22:30</MON-FRI>
<SAT> 08:00 - 11:30, 12:30- 15:45</SAT>
<SUN>11:30-18:00 </SUN>
</OPENINGTIMES>
<ACCEPTEDCARDS>American express, Delta, Mastercard, Meatro, Visa</ACCEPTEDCARDS>
<HOUSEREDPRICE>18 </HOUSEREDPRICE>
<HOUSEWHITEPRICE>18</HOUSEWHITEPRICE>
<SERVICECHARGE OPTIONAL="TRUE">12.5% </SERVICECHARGE>
</RESTAURANT>
<RESTAURANT STATUS="FEATURED" BOOKONLINE="TRUE" CHILDRENWELCOME="TRUE" GROUPSALLOWED="TRUE" AIRCONDITIONING="TRUE" OUTSIDESEATING="FALSE" RESERVATIONS="TRUE" COVERCHARGE="FALSE">
<NAME>Blueprint Cafe
</NAME>
<ADDRESS>
<STREETNUMBERORNAME>Design Musuem</STREETNUMBERORNAME>
<STREETNAME>Butlers Wharf</STREETNAME>
<CITY>London</CITY>
<POSTCODE>SE1 2YD</POSTCODE>
<COUNTRY>United Kingdom</COUNTRY>
</ADDRESS>
<CUISINE>Modern British</CUISINE>
<AVGLUNCH>26</AVGLUNCH>
<AVGDINNER>45</AVGDINNER>
<CONTACT>
<TEL>+44(0)2073787031</TEL>
<EMAIL>
[email protected]</EMAIL>
<WEBSITE>http://www.blueprintcafe.co.uk/</WEBSITE>
</CONTACT>
<SEASONAL>Fixed Price Dinner Menu 2 courses for £22.50 / 3 courses for £27.50</SEASONAL>
<OPENINGTIMES>
<MON-SAT>12:00-15:00,18:00-23:00</MON-SAT>
<SUN>12:00-16:00 </SUN>
</OPENINGTIMES>
<REVIEW DATE="17 October 2007">
<NAME>Josy</NAME>
<INFO>We went there for my husband's birthday after receiving vouchers for a two course meal. The view is impressive and the cafe is located in a great area, right next to Tower Bridge. When we arrived we ordered a mojito and a gin and tonic. The waitress looked at me blankly and repeated mojito, but took the order and left the table. What returned was some kind of rum based drink with no mint or sugar, clearly not a mojito. Nevertheless, I drank it, though in hindsight should've complained then.
The starters were the highlight of the meal, the chicken liver pate was served with toasted bread, which was nice but nothing special and the salsify was coated delicately with parmesan, the highlight of the meal. The vegetarian main was polenta, I chose it because there were only three choices, and I didn't want fish, artichoke and goatsâ cheese. It was quite bland and needed something like pesto to give it life. The beef main, which my husband had, was delicious and tender, if not too salty.
In such a great environment and considering we were early and it was not that busy, I would've expected better service. We also ordered dessert - the crème brulee came out with the top quite burnt, however the lemon dessert was delicious and creamy. Would I recommend it? Probably not due to me not thinking that we got value for money .And if they serve cocktails they should at least know what a mojito is. Mainly we found the waitress unwilling to please or help and didn't seem to be able to answer any questions about the menu. </INFO>
</REVIEW>
<ACCEPTEDCARDS>American Express, MasterCard, Meastro, Visa</ACCEPTEDCARDS>
<HOUSEREDPRICE> 15</HOUSEREDPRICE>
<HOUSEWHITEPRICE>15</HOUSEWHITEPRICE>
<SERVICECHARGE OPTIONAL="TRUE"> 12.5%</SERVICECHARGE>
</RESTAURANT>
<RESTAURANT STATUS="FEATURED" BOOKONLINE="TRUE" CHILDRENWELCOME="TRUE" GROUPSALLOWED="TRUE" AIRCONDITIONING="TRUE" OUTSIDESEATING="TRUE" RESERVATIONS="TRUE" COVERCHARGE="FALSE">
<NAME>Cantina Del Ponte
</NAME>
<ADDRESS>
<STREETNUMBERORNAME>Butlers Wharf Building, 36C</STREETNUMBERORNAME>
<STREETNAME>Shad Thames</STREETNAME>
<CITY>London</CITY>
<POSTCODE>SE1 2YE</POSTCODE>
<COUNTRY>United Kingdom</COUNTRY>
</ADDRESS>
<CUISINE>Italian</CUISINE>
<AVGLUNCH>25</AVGLUNCH>
<AVGDINNER>40</AVGDINNER>
<CONTACT>
<TEL>+44(0)2074035403</TEL>
<EMAIL>
[email protected]</EMAIL>
<WEBSITE>http://www.cantina.co.uk/</WEBSITE>
</CONTACT>
<SEASONAL>Fixed Price Lunch Set Menu 2 courses £10.95 or 3 courses £13.95</SEASONAL>
<SEASONAL>Fixed Price Dinner Set Menu 2 courses inc glass of wine £15.75 or 3 courses inc glass of wine £18.75</SEASONAL>
<OPENINGTIMES>
<MON-SAT>12:00-15:00,18:00-23:00</MON-SAT>
<SUN>12:00-15:00,18:00-22:00 </SUN>
</OPENINGTIMES>
<REVIEW DATE="8 February 2008">
<NAME>Ricky</NAME>
<INFO>I have used this resturant many times and find it truly Italian, with a varied menu, friendly staff and a lovely view of the Thames. In summer it's great to sit outside - for its location, the prices are very reasonable. </INFO>
</REVIEW>
<REVIEW DATE="6 December 2004">
<NAME> Michelle Owens</NAME>
<INFO>Iâm sorry to say that my overall dining experience did not meet my expectations. The ambiance was lovely and the staff were very professional and helpful but the menu was very limited and I feel not enough was done to accommodate vegetarians. The options available were also unimaginative and predictable. To be honest, I felt a little let down.
The meat options were lovely, but I cannot help but feel that more could have been done to accommodate us - it is after all a restaurant with a kitchen and a chef. I would most likely not visit the establishment again and would have some reserve booking a table again, especially if I have vegetarian guests. A nice restaurant for meat lovers however.</INFO>
</REVIEW>
<ACCEPTEDCARDS>American Express, MasterCard, Meastro, Visa</ACCEPTEDCARDS>
<HOUSEREDPRICE> 13.50</HOUSEREDPRICE>
<HOUSEWHITEPRICE>13.50</HOUSEWHITEPRICE>
<SERVICECHARGE OPTIONAL="TRUE"> 12.5%</SERVICECHARGE>
</RESTAURANT>
</RESTAURANTGUIDE>
My xslt: =================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="RESTAURANTGUIDE">
<html>
<head>
<style type="text/css">
body {
background-color : #993300}
</style>
<style type="text/css">
table {
color: yellow;
background-color: black }
</style>
<style type="text/css">
p:first-letter {
Font-size : 200%;
font-weight : bold;
vertical-align : middle;
}
</style>
<style type="text/css">
p {
background-color : yellow;
text-align: center;
text-size:large}
</style>
<style type="text/css">
ul {
list-style-type: none;
background-image: url(navi_bg.png);
height: 80px;
width: 663px;
margin: auto;
background-color :black;
}
</style>
<style type="text/css">
ul li{
float: left;
display : block}
</style>
<style type="text/css">
ul a {
background-image: url(navi_bg_divider.png);
background-repeat: no-repeat;
background-position: right;
padding-right: 32px;
padding-left: 32px;
display: block;
line-height: 80px;
text-decoration: none;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 21px;
color:#999933 ;
}
</style>
<style type="text/css">
#tablehead {
text-align : center;
vertical-align: middle;
backround-color: #FFCC00;
border-color :yellow}
}
</style>
<title>Restaurant Guide</title>
</head>
<body>
<p> List Of Restaurants</p>
<h1> Sort By:</h1>
<ul>
<li><a href="seasonal.html"> Lunch < 30</a></li>
<li><a href="italian.html"> Featured</a></li>
<li><a href="british.html"> Selected</a></li>
<li><a style="background-image :none;" href="full-list.html"> Seasonal </a></li>
</ul>
<ul>
<li><a href="seasonal.html"> Dinner < 30</a></li>
<li><a href="italian.html"> Italian</a></li>
<li><a href="british.html"> Modern British</a></li>
<li><a style="background-image :none;" href="full-list.html"> Full List</a></li>
</ul>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="RESTAURANT[SEASONAL]">
<tr><td>
<xsl:value-of select="NAME"/>
</td>
<td>
<xsl:value-of select="ACCEPTEDCARDS"/>
</td>
<td>
<xsl:value-of select="ADDRESS"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
my DTD==================================
<?xml version="1.0" encoding="UTF-16LE"?>
<!ELEMENT RESTAURANTGUIDE (RESTAURANT*) >
<!ELEMENT RESTAURANT (NAME, INFO, ADDRESS, ( CUISINE| AVGLUNCH | AVGDINNER | CONTACT| SEASONAL| OPENINGTIMES|REVIEW|ACCEPTEDCARDS)*) >
<!ATTLIST RESTAURANTGUIDE
STATUS (FEATURED | SELECTED | NORMAL) "NORMAL"
BOOKONLINE (TRUE| FALSE) "FALSE"
CHILDRENWELCOME (TRUE| FALSE) "TRUE"
GROUPSALLOWED (TRUE| FALSE) "TRUE"
AIRCONDITIONING (TRUE| FALSE) "TRUE"
OUTSIDESEATING (TRUE| FALSE) "FALSE"
RESERVATIONS (TRUE| FALSE) "TRUE"
COVERCHARGE (TRUE| FALSE) "FALSE" >
<!ELEMENT NAME (#PCDATA) >
<!ELEMENT INFO (#PCDATA) >
<!ELEMENT ADDRESS (STREETNUMBER| STREETNAME|CITY|POSTCODE|COUNTRY)*>
<!ELEMENT STREETNUMBERORNAME (#PCDATA) >
<!ELEMENT STREETNAME (#PCDATA) >
<!ELEMENT CITY (#PCDATA) >
<!ELEMENT POSTCODE (#PCDATA) >
<!ELEMENT COUNTRY (#PCDATA) >
<!ELEMENT CUISINE (#PCDATA) >
<!ELEMENT AVGLUNCH (#PCDATA) >
<!ELEMENT AVGDINNER (#PCDATA) >
<!ELEMENT CONTACT (TEL| EMAIL| WEBSITE)* >
<!ELEMENT TEL (#PCDATA) >
<!ELEMENT EMAIL (#PCDATA) >
<!ELEMENT WEBSITE (#PCDATA) >
<!ELEMENT SEASONAL (#PCDATA) >
<!ELEMENT OPENINGTIMES (MON-THURS|MON-FRI| MON-SAT| FRI-SAT| SUN)* >
<!ELEMENT MON-THURS (#PCDATA) >
<!ELEMENT MON-FRI (#PCDATA) >
<!ELEMENT MON-SAT (#PCDATA) >
<!ELEMENT FRI-SAT (#PCDATA) >
<!ELEMENT SAT-SUN (#PCDATA) >
<!ELEMENT SAT (#PCDATA) >
<!ELEMENT SUN (#PCDATA) >
<!ELEMENT REVIEW (NAME, INFO) >
<!ATTLIST REVIEW
DATE CDATA #REQUIRED >
<!ELEMENT ACCEPTEDCARDS (#PCDATA) >
<!ELEMENT HOUSEREDPRICE (#PCDATA) >
<!ELEMENT HOUSEWHITEPRICE (#PCDATA) >
<!ELEMENT SERVICECHARGE (#PCDATA) >
<!ATTLIST SERVICECHARGE
OPTIONAL (TRUE|FALSE) "FALSE" >