Валиков Алексей Н.
Шрифт:
<xsl:template match="Param" mode="header">
<xsl:text>Request parameters</xsl:text>
</xsl:template>
<xsl:template match="Session" mode="header">
<xsl:text>Session parameters</xsl:text>
</xsl:template>
<xsl:template match="Cookie" mode="header">
<xsl:text>Cookies</xsl:text>
</xsl:template>
<xsl:template match="*" mode="row">
<tr>
<td><xsl:apply-templates select="." mode="name"/></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:template>
<xsl:template match="*" mode="name">
<xsl:value-of select="name"/>
</xsl:template>
<xsl:template match="General/ServerName" mode="name">
<xsl:text>Server name</xsl:text>
</xsl:template>
<xsl:template match="General/ServerPort" mode="name">
<xsl:text>Server port</xsl:text>
</xsl:template>
<xsl:template match="General/RemoteAddr" mode="name">
<xsl:text>Remote address</xsl:text>
</xsl:template>
<xsl:template match="General/RequestURI" mode="name">
<xsl:text>Request URI</xsl:text>
</xsl:template>
<xsl:template match="General/QueryString" mode="name">
<xsl:text>Query string</xsl:text>
</xsl:template>
</xsl:stylesheet>
Результатом этого преобразования является следующий HTML-документ, внешний вид которого полностью идентичен документу, показанному на рис. 9.13.
Листинг 9.26. Результирующий HTML-документ
<html>
<head>
<title>Request information</title>
</head>
<body>
<h1>General information</h1>
<table>
<tr>
<td>Server name</td>
<td>aphrodite.fzi.de</td>
</tr>
<tr>
<td>Server port</td>
<td>80</td>
</tr>
<tr>
<td>Remote address</td>
<td>127.0.0.1</td>
</tr>
<tr>
<td>Protocol</td>
<td>HTTP/1.1</td>
</tr>
<tr>
<td>Method</td>
<td>GET</td>
</tr>
<tr>
<td>Request URI</td>
<td>/servlet/example1</td>
</tr>
<tr>
<td>Query string</td>
<td>x=1&y=2&z=3&x=4&y=5&z=6</td>
</tr>
</table>
<h1>Request parameters</h1>
<table>
<tr>
<td>z</td>
<td>3</td>