home—lects—exams—hws
D2L—breeze (snow day)
hw06-reviews
XSLT and DTDs
a videogame encyclopedia
Due: 2012.Dec.07 (Fri) 23:59
We will work with an XML-encoded database of information
about videogames, reviews.xml.
- (5pts)
Add one more game to the file.
- (20pts)
Create an XSLT template
which generates a page with a summary of each game,
looking similar to reviews-goal.html
(you are encouraged to view-source).
- (2pts extra-credit)
Have your review-summary-score should be a link
to a page whose URL is (say)
reviews#Portal_2;
this link does not actually have to be a valid link;
I want to see that you know how to add attributes to a tag.
(For an additional 2pts extra-credit,
you can use translate to convert characters that shouldn't be in
a URL into safe characters (perhaps all underscores).)
- (2pts extra-credit)
Dates (years,months,and day) should be padded with leading zeroes.
-
(2pts extra-credit)
Note that if there is no language tag (as with Super Mario Galaxy),
you won't list that category at all in the html.
Hint: remember the count function.
-
2pts extra-credit for listing the platforms (etc.) without
a trailing comma, and including the word “and” before the last item.
(Cf. the list of names of the wonders, with commas.)
-
2pts extra-credit for not having an “s” at the end
of “Platforms:” (and, “Languages:”)
when there is only one thing in the list.
- (5pts)
Have your list sorted by
release-year, in reverse order (most recent first).
(To test that this is working,
have the game which you entered be in a different order than the output.)
(2pts extra-credit:
If you want,
you can use nested xsl:sort tags to
sort by year-month-day1.
Arrange the games in the source-file to make sure this sorting work.)
- (15pts)
Generate a DTD for the grammar
(You can have the DTD either in-line in your xml file, or as an external file.)
Validate the file, using the validator such as the one at
http://www.xmlvalidation.com/.
If you include the DTD in-line,
enclose all your
<!ELEMENT…>
and
<!ATTLIST…>
information inside a single, enclosing
<!DOCTYPE games [ … ]>:
.
<?xml … ?>
<!DOCTYPE games [
<!ELEMENT wonders (wonder*)>
<!ELEMENT wonder …>
<!ATTLIST name
lang …>
⋮
]>
|
- (5pts)
Define entities2 &ps3;,
&wiiU;, etc.
Please have your page
(a) at https://php.radford.edu/~yourUserId/itec325/hw06/hw06.xml,
with your other file(s)
named hw06.xsl
and (if in a separate file) hw06.dtd;
and
(b) those same files submitted on D2L.
Tips:
-
Work incrementally.
-
Make sure your xml and xsl files are publically readable.
-
Getting no output at all?
Make sure your xsl tags are all properly closed.
-
When using an xsl:attribute tag,
don't include any extra whitespace in the body;
this gets turned into whitespace in the attribute which is presumably
not what you want.
1This is actually following a standard CS trick:
If you first sort by month and then by year,
you'll get what you want as long as the sorting algorithm
is
“stable”
— that is,
it leaves tied elements in the same relative order they started in.
It makes sense: after the first sort on months,
all the Januaries come before all the Februaries.
When you now sort by year, and two games are tied for year,
the January one will stay ahead of the February one, in a stable sort.
↩
2Okay okay,
if you get technical, the “&” and
“;” aren't part of the entity.
Still, you know what I mean. ↩
home—lects—exams—hws
D2L—breeze (snow day)