|
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). Here is a sample/starter movies.xsl (also View Source, to get the initial xml-declaration lines!). Submit your files on D2L, with the exact names “movies.xml”, “movies.xsl”, and (if opting for external-dtd) “movies.dtd”.
Have your review-summary-score be a link to a page whose URL is (say) full-reviews.xml#Metropolis. 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
viewing the file: If you open your .xml file locally, either (a) use Firefox, or (b) in Chrome you need to provide the command-line switch, something like:/Applications/Google\ Chrome.app/contents/MacOS/Google\ Chrome --allow-file-access-from-files .
Tips:
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
<?xml … ?> <!DOCTYPE ancient_wonders [ <!ELEMENT wonders (wonder*)> <!ELEMENT wonder …> <!ATTLIST name lang …> ⋮ ]> |
The easiest solution is to compose two calls to translate:
the first does most of the work, and then you pass the result
to another call to
For XSLT 1.0, another solution is to use variables and concatenation, to create a single string with both types of quotes in it:
<xsl:variable name="quot">"</xsl:variable> <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
home—lects—hws
D2L—breeze (snow day)
©2017, Ian Barland, Radford University Last modified 2017.May.04 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |