Выбрать главу

  <QueryString>x=1&amp;y=2&amp;z=3&amp;x=4&amp;y=5&amp;z=6

  </QueryString>

 </General>

 <Param>

  <z>3</z>

  <z>6</z>

  <y>2</y>

  <y>5</y>

  <x>1</x>

  <x>4</x>

 </Param>

 <Session>

  <v>4</v>

 </Session>

 <Cookie>

  <content>apple jam</content>

  <JServSessionIdroot>aaenbyjqc0</JServSessionIdroot>

 </Cookie>

</Request>

После того как генерация документа завершена, к нему применяется преобразование stylesheet.xsl, которое создает его HTML-представление.

Листинг 9.25. Преобразование stylesheet.xsl

<xsclass="underline" stylesheet

 version="1.0"

 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsclass="underline" template match="Request">

  <html>

   <head>

    <title>Request information</title>

   </head>

   <body><xsclass="underline" apply-templates mode="table"/></body>

  </html>

 </xsclass="underline" template>

 <xsclass="underline" template match="*" mode="table">

  <h1><xsclass="underline" apply-templates select="." mode="header"/></h1>

  <table><xsclass="underline" apply-templates mode="row"/></table>

 </xsclass="underline" template>

 <xsclass="underline" template match="General" mode="header">

  <xsclass="underline" text>General information</xsclass="underline" text>

 </xsclass="underline" template>

 <xsclass="underline" template match="Param" mode="header">

  <xsclass="underline" text>Request parameters</xsclass="underline" text>

 </xsclass="underline" template>

 <xsclass="underline" template match="Session" mode="header">

  <xsclass="underline" text>Session parameters</xsclass="underline" text>

 </xsclass="underline" template>

 <xsclass="underline" template match="Cookie" mode="header">

  <xsclass="underline" text>Cookies</xsclass="underline" text>

 </xsclass="underline" template>

 <xsclass="underline" template match="*" mode="row">

  <tr>

   <td><xsclass="underline" apply-templates select="." mode="name"/></td>

   <td><xsclass="underline" value-of select="."/></td>

  </tr>

 </xsclass="underline" template>

 <xsclass="underline" template match="*" mode="name">

  <xsclass="underline" value-of select="name()"/>

 </xsclass="underline" template>

 <xsclass="underline" template match="General/ServerName" mode="name">

  <xsclass="underline" text>Server name</xsclass="underline" text>

 </xsclass="underline" template>

 <xsclass="underline" template match="General/ServerPort" mode="name">

  <xsclass="underline" text>Server port</xsclass="underline" text>

 </xsclass="underline" template>

 <xsclass="underline" template match="General/RemoteAddr" mode="name">

  <xsclass="underline" text>Remote address</xsclass="underline" text>

 </xsclass="underline" template>

 <xsclass="underline" template match="General/RequestURI" mode="name">

  <xsclass="underline" text>Request URI</xsclass="underline" text>

 </xsclass="underline" template>

 <xsclass="underline" template match="General/QueryString" mode="name">

  <xsclass="underline" text>Query string</xsclass="underline" text>

 </xsclass="underline" template>

</xsclass="underline" 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&amp;y=2&amp;z=3&amp;x=4&amp;y=5&amp;z=6</td>

   </tr>

  </table>

  <h1>Request parameters</h1>

  <table>

   <tr>

    <td>z</td>

    <td>3</td>

   </tr>

   <tr>

    <td>z</td>

    <td>6</td>

   </tr>

   <tr>

    <td>y</td>

    <td>2</td>

   </tr>

   <tr>

    <td>y</td>

    <td>5</td>

    </tr>

   <tr>

    <td>x</td>

    <td>1</td>

   </tr>

   <tr>

    <td>x</td>

    <td>4</td>

   </tr>

  </table>

  <h1>Session parameters</h1>

  <table>

   <tr>

    <td>v</td>

    <td>4</td>