Expert Spring MVC and Web Flow

(Dana P.) #1
Moscow
100


The name of the root element () was in this case set by the Controllerwhen it
returned a single object as the model. The root name takes the name of a single model param-
eter in these cases.
If your model contains more than one object, though, you can set a root name in the
views.propertiesfile that we looked at in Listing 8-32. The value of a home.rootproperty
would be passed into our createXsltSourcemethod as the second parameter (String root).
If you don’t set one, your XML will have a root element of .
To complete the picture, our stylesheet that we instructed the ViewResolverto load from
/WEB-INF/xsl/home.xsltis shown in Listing 8-35.


Listing 8-35.Home Page Stylesheet


<?xml version="1.0"?>


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:template match="/">

<html>
<head><title>Flight Booking Service</title></head>

<body>
<h1>Welcome to the Flight Booking Service</h1>
<p>We have the following specials now:</p>

<ul>
<xsl:for-each select="/specials/deal">
<li>
<xsl:value-of select="./from"/> -
<xsl:value-of select="./to"/> from
<xsl:value-of select="./cost"/>
</li>
</xsl:for-each>
</ul>

<p><a href="search">Search for a flight.</a></p>

</body>
</html>

</xsl:template>


CHAPTER 8 ■SUPPORTED VIEW TYPES 253
Free download pdf