Lab 4: XSLT



Due Tuesday 2/27 at start of class.
30 points
. Note: For this lab, no late assignments will be accepted. I will ask you to demo your lab in class on the 27th.

In this lab, you'll get some experience using XSLT to transform XML documents. Many of you noticed that there was a "missing piece" from last week's lab. Once you'd added tags to a picture, there was no way to display them in the HTML you'd generated. This is because the HTML was generated statically, rather than dynamically. In this lab, we'll modify your server-side program to use XSLT to generate HTML on the fly.

  1. (10 points) Write an XSLT stylesheet that can transform your picture database into an HTML webpage similar to the one you generated for last week's lab. (You may put all of the pictures on one page if you want, or you can have multiple pages.) It should include any tags that are in the XML. Modify your CGI script so that, after a tag is added, the main picture gallery is displayed again, with the new tags.
  2. (10 points) Add filter functionality to your application. The user should be able to specify picture features (such as filename, directory, tag, or EXIF value) and see only those pictures that fit that description. You should use this query to search your XML database with your DOM parser and return the XML corresponding to the specified features. You should use XSLT to then transform this to HTML. Please note that this is fairly broadly specified; as long as the essential requirements are met (XML queried via DOM, XSLT used to generate HTML, user is able to dynamically select a subset of pictures to view) you may implement however you like.
  3. (10 points) style. Make your application look good and function well. This might mean more flexible search functionality, or a slick user interface, or nice design, or something else altogether. Be creative! In assigning points, I will consider both what you've done and also how it compares to your classmates. Please note that I am much more impressed with a clean, easy-to-use design that you came up with yourself than something flashy and slick that you get more or less verbatim from a website or toolkit.
Note: There is one fairly challenging hurdle you will have to deal with in this project: How to include closing tags for a row (either </tr> or < /div>). I am NOT going to tell you exactly how to solve this. Think of it as a forced exercise in problem solving. There are several solutions, all of which can be found online or in the course reading with a little exploration. Understanding how XSLT works, that a transform is a valid XML document that emits strings as a result of matches on document nodes, will make this problem easier to solve.