home—lects—hws
D2L—breeze (snow day)
movies
XSLT and DTDs
a movie encyclopedia
Due: 2014.Dec.11 (Thu) 16:59
We will work with an XML-encoded database of information
about movies, movies.xml.
(And, here is a sample/starter movies.xsl.)
Submit your files on D2L,
with the names “movies.xml” and “movies.xsl”
(and, if a separate file, “movies.dtd”).
- (5pts)
Add one more movie to the file.
- (20pts)
Create an XSLT template
which generates a page with a summary of each movie,
looking similar to movies-goal.html
(you are encouraged to view-source).
- Feel free to make your page look nicer than that demo.
- (2pts extra-credit)
Have your review-summary-score should be a link
to a page whose URL is (say)
full-reviews.xml#Birdman;
this link does not actually have to be a valid link;
I just want to see that you know how to add attributes to a tag.
(For an additional 2pts extra-credit,
use translate to convert
spaces to hyphens,
and certain black-listed characters that don't belong in URLs
into safe characters (e.g. underscores).)
-
(2pts extra-credit)
Note that if the language is English, or there is no language tag,
you won't list the movies languages at all.
Similarly, if there is no rating given, list as "Rating: Unrated".
Finally, if there is no studio, omit the “by” clause next to the date.
Hint: remember the count function.
-
2pts extra-credit for listing the actors (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 “Genre:”
when there is only one genre for the movie.
- (5pts)
Have your list sorted by
release-year, in reverse order (most recent first).
(2pts extra-credit:
If you want,
you can use nested xsl:sort tags to
sort by year-month-day1.
Re-arrange the games in the source-file in such an order
as to confirm that this sorting works.)
- (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/.
Your DTD must match the three provided movies.
Use your best judgement about whether a field that occurs in all three
is required, or optional, or allowed to have multiple entries.
If you include the DTD in-line,
enclose all your
<!ELEMENT…>
and
<!ATTLIST…>
information inside a single, enclosing
<!DOCTYPE games [ … ]>:
.
<?xml … ?>
<!DOCTYPE ancient_wonders [
<!ELEMENT wonders (wonder*)>
<!ELEMENT wonder …>
<!ATTLIST name
lang …>
⋮
]>
|
- (5pts)
Define entities2
&ps3;,
&wiiU;, &xbox1;
&PG13;, &R;
(or, perhaps entities for certain common studios), etc.
Tips:
-
Work incrementally.
-
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.
The ampersand and semicolon are part of how you denote an entity-literal.
Similarly, in programming languages, quotes aren't part of the string but just
how you denote what the string-literal is.
↩
home—lects—hws
D2L—breeze (snow day)