|
home—lects—hws
D2L—breeze (snow day)
Due:
We will work with an XML-encoded database of information about movies, movies.xml [be sure to View Source!]. (And, here is a sample/starter movies.xsl.) Submit your files on D2L, with the names “movies.xml” and “movies.xsl”.
Have your review-summary-score be a link to a page whose URL is (say) full-reviews.xml#Birdman. This link does not need to lead to an actual, existing page; I just want you to demonstrate that you know how to add attributes to a tag.
For full credit,
use
hint:Recall the example of usingposition() , near the end of xpath-functions/. If you like, include the word “and” before the last item.
If you want,
you can use nested
Tips:
1
This is not as effective as a function like php's
For 1.0, one solution is to use variables and concatenation, to create a string with both types of quotes in it:
<xsl:variable name="apos">'</xsl:variable> <xsl:value-of select="…concat('abc',$apos,'def',$quot,'ghi')…"/> |
But this digression is further than I want to go in this course —
I want to focus on the ideas of XPATH,
understanding the need for sanitizing,
and reinforcing the notion of calling functions (in new languages).
And if you were really using XSLT,
hopefully you'd be finding support for XSLT 2.0,
and you could just call its function
3This 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 movies are tied for year, the January one will stay ahead of the February one, in a stable sort. ↩
home—lects—hws
D2L—breeze (snow day)
©2015, Ian Barland, Radford University Last modified 2016.Apr.20 (Wed) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |