You are on page 1of 2

Lab 2 Part 1 Getting a List of Electric Juicers The purpose of this lab is for you to get hands-on experience

e with using XSL variables and the if statement. For this lab you are to create an HTML document containing a list of electric juicers. Heres what your output should look like: This juicer is electric: Champion Juicer This juicer is electric: Green Power Gold Juice Extractor This juicer is electric: Juiceman Jr. This juicer is electric: Omega Juicer This juicer is electric: Wheateena Wheatgrass Juicer That is, for each electric juicer you should output This juicer is electric: followed by the name of the juicer. Heres how you are to implement this: For each juicer Get the name of the juicer and store it into a variable Get the value of the element/attribute which indicates whether it is electric and store it in a variable Test the value of the is electric variable to see if it indicates that the juicer is electric. If it does indicate that the juicer is electric then Output the text This juicer is electric: Output the value of the juicer name variable Output an HTML break Part 2 Interested in Knowing if the Juicers XML document contains these juicers

This lab will strengthen your understanding and experience with XSL variables. Also, if will give you experience with the string function, contains(). For this lab you are to create a variable which holds a list of all the juicer names (separated by tildas) in the XML document. You are then to determine if this list contains, Champion, Omega, and Ultrex. You should output the value of the variable which holds the list of all the juicer names. After that you should output a line for each juicer that we are interested in. Heres what the output should look like: Juicer List: OJ Home Juicer~Champion Juicer~Green Power Gold Juice Extractor~Juiceman Jr.~Omega Juicer~Wheateena Wheatgrass Juicer - contains Champion - contains Omega - does not contain Ultrex Note that there is no tilda after the last juicer in the juicer list. (hint) Part 3 Processing Airports in Differing Formats There are several different ways to identify airports:

ICAO code: e.g., BOS is the ICAO code for the Boston airport Lat/Lon: e.g., 74.3N, 123.0W is the lat/lon of the Boston airport

In this directory you will find Airports.xml: <?xml version="1.0"?> <airports> <location>ICAO: bos</location> <location>LatLon: 74.31w, 106.5n</location> <location>ICAO: slt</location> <location>ICAO: mol</location> <location>Bogus!</location> <location>LatLon: 43.01w, 116.8n</location> </airports> The contents of a <location> element is a string with one of the following two forms: ICAO: code or LatLon: value For this lab you are to create an HTML document which processes each <location> element. Where the data is of the form ICAO: code you are to output: ICAO = code, where the data is of the form LatLon: value you are to output LatLon = value. Note: you are to convert the code and value data to upper case. Heres what the output should look like: ICAO = BOS LatLon = 74.31W, 106.5N ICAO = SLT ICAO = MOL Data Error! Data must be formatted as: ICAO: code, or LatLon: value LatLon = 43.01W, 116.8N Part 4 Computing the Average Cost for a Juicer For this lab you are to create an HTML document that calculates the average cost for a juicer. Note: to make things simpler I have modified juicers.xml to contain only the juicer cost in USD. Heres what your output should look like: Total number of juicers = 6 Cost of all juicers = 1696.93 The average cost of the juicers = $282.82 Hint: to format a number to have two digits to the right of the decimal point, along with a dollar sign in front of the number, use the XSL function: format-number($avgCost, $#.00)

You might also like