Chapter 15
634
Again, we are generating an XML document instead of HTML here. Note the way we have included the
<triplist> outermost element, and added the heading as an additional element. This highlights one
of the major differences between XSLT-styled formatting and transformation as opposed to CSS-based
formatting. With CSS, the flow and structure of the underlying XML document must be very close to
the transformed output. XSLT, on the other hand, allows data to be extracted from the original XML
document and displayed in an arbitrary fashion. One will likely find XSLT-based formatting support in
a later version of Netscape browser.
The associated stylesheet is now of the text/css type, and is called trip.css. The CSS2 stylesheet
trip.css is quite simple:
title, topic { display: block }
title { font-family: Times; font-size: 28pt; font-weight: bold }
topic { font-family: Times; font-size: 18pt; margin:20px; }
trip { display: table-row; font-family: Helvetica; font-size: 12pt }
location { display: table-cell }
startdate { display: table-cell }
price { display: table-cell }
duration { display: table-cell }
This essentially says that elements topic and titles are ones that starts a block (like HTML tags
<title>, <p>, etc.), and does not flow in-line (like HTML tags <b>, <i>, <font>, etc.). Tags that start
a block will cause any content to be placed in a new block, while tags that flow in-line will not. The rest
of the file formats the various elements, and specifies that location, startdate, and price are table
cells, while trip is a table row.
You can access this JSP page via the URL:
http://localhost:8080/vacserv/jsp/NScss2.jsp
The result should be identical to the screenshot below: