Database Reference
In-Depth Information
By the way: maybe you shouldn't go for the role of Hamlet—almost 1,500 lines with
11,500 words is a lot to learn by heart. And have mercy on the director: finding and
directing 35 actors is not exactly a walk in the park!
Linking the Analysis to the Play Overview
At this moment our application still consists of two different pages: an overview and
an analysis page for Hamlet . So how can we tie these together and use the analysis
page for every play?
To do this, we first need to link from our overview to our analysis page and pass the
URI of the play to analyze in the link. Go back to our basic home page ( Example 3-6 )
and change the line starting with <li> as follows:
<li> {string($play)} ({string($play/@name)})
<a href= "analyze-play.xq?uri={encode-for-uri($play/@uri)}" > analysis </a>
</li>
The a element (that produces an HTML link) links to the analysis page and passes the
URI of the play in the uri parameter. The encode-for-uri function is necessary here
because the URI passed contains characters that are misinterpreted if we pass them
straight: encode-for-uri creates % encodings for them, e.g., %2F for a slash ( / )
character.
An interesting phenomenon occurs when you use this technique
for Romeo and Juliet . Remember, the URI for this play already con‐
tains URI-escaped characters (the spaces in the resource name: r
%20and%20j.xml ). Passing this URI through the encode-for-uri
function means the URI will become double URI encoded! The
resource name is passed as r%2520and%2520j.xml .
The second thing we have to do is change our analysis page to retrieve the URI in the
uri parameter and act on this. For this, change the declaration of the $play-uri vari‐
able to:
declare variable $ play-uri as xs:string := request:get-parameter ( 'uri' , ());
request:get-parameter is an extension function from the request extension module
(see “The request Extension Module” on page 209 ) that returns the value of a parameter
passed in the URL (or of a control in an HTML form−driven request). The second
parameter, which in this example is the empty sequence () , can be used to pass a
default value.
After making these changes you can analyze not only Hamlet , but all three of the
plays (and assuming you can provide the data, then many more). Neat, isn't it?
Search WWH ::




Custom Search