You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by st...@locus.apache.org on 2000/01/03 02:37:24 UTC
cvs commit: xml-cocoon/samples/xsp clean-page.xml lib-page.xml page-html.xsl page-xsp.xsl page.xml view-source.xml page.xsl page.xsp sample.xml sample.xsl snoop.xml
stefano 00/01/02 17:37:24
Modified: samples/xsp page.xml view-source.xml
Added: samples/vrml hello-vrml.xsl hello.xml
samples/xsp clean-page.xml lib-page.xml page-html.xsl
page-xsp.xsl
Removed: samples/xsp page.xsl page.xsp sample.xml sample.xsl
snoop.xml
Log:
new XSP + VRML samples
Revision Changes Path
1.1 xml-cocoon/samples/vrml/hello-vrml.xsl
Index: hello-vrml.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="page">
<xsl:processing-instruction name="cocoon-format">type="model/vrml"</xsl:processing-instruction>
<!-- due to a DOM limitation, you must wrap your generated VRML
with a fake tag, here uses <vrml>, that is stripped out by the
VRML formatter -->
<vrml><xsl:text>#VRML V2.0 utf8</xsl:text>
<xsl:apply-templates select="content"/>
</vrml>
</xsl:template>
<xsl:template match="content">
<xsl:text>
Transform {
translation 0 0 9
rotation 0 0 1 0.0
children Shape {
appearance DEF WHITE Appearance {
material Material {
diffuseColor 1 1 1
}
}
geometry Text {
string [ " </xsl:text><xsl:value-of select="paragraph"/><xsl:text> " ]
fontStyle DEF MFS FontStyle {
size 0.1
family "SERIF"
style "BOLD"
justify "MIDDLE"
}
}
}
}
</xsl:text>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon/samples/vrml/hello.xml
Index: hello.xml
===================================================================
<?xml version="1.0"?>
<?xml-stylesheet href="hello-vrml.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
<!-- Written by Stefano Mazzocchi "stefano@apache.org" -->
<page>
<title>Hello</title>
<content>
<paragraph>This is my first Cocoon file!</paragraph>
</content>
</page>
1.3 +128 -46 xml-cocoon/samples/xsp/page.xml
Index: page.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/samples/xsp/page.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- page.xml 1999/11/20 01:18:38 1.2
+++ page.xml 2000/01/03 01:37:23 1.3
@@ -1,50 +1,132 @@
<?xml version="1.0"?>
-<?xml-stylesheet href="page.xsl" type="text/xsl"?>
-<?cocoon-process type="xslt"?>
-<page>
- <title>First XSP Page</title>
- <author>
- <name>Stefano Mazzocchi</name>
- <address>stefano@apache.org</address>
- </author>
- <version>$Id: page.xml,v 1.2 1999/11/20 01:18:38 stefano Exp $</version>
+<!-- Author: Stefano Mazzocchi "stefano@apache.org" -->
+<!-- Version: $Id: page.xml,v 1.3 2000/01/03 01:37:23 stefano Exp $ -->
- <p>Hi, I'm the <em>first XSP page ever</em>.</p>
-
- <p>This page is an example of usage for XSP technology which is being
- designed to add dynamic XML capabilities to the Cocoon publishing
- framework.</p>
-
- <p>In this page, the content is automatically generated by translating this
- template page into some source code (Java in this case) and then executed
- at request time (as servlet). The separation between content and logic
- is done using the transformation capabilities of XSL, tranforming the
- template elements used to create this page into XSP elements which
- discriminate the content from the logic and are correctly interpretable
- from an XSP engine.</p>
-
- <request-data title="Request Data">
- <data name="Request method" value="Method"/>
- <data name="Request URI" value="RequestURI"/>
- <data name="Request protocol" value="Protocol"/>
- <data name="Servlet path" value="ServletPath"/>
- <data name="Path info" value="PathInfo"/>
- <data name="Path translated" value="PathTranslated"/>
- <data name="Query string" value="QueryString"/>
- <data name="Content length" value="ContentLength"/>
- <data name="Content type" value="ContentType"/>
- <data name="Server name" value="ServerName"/>
- <data name="Server port" value="ServerPort"/>
- <data name="Remote user" value="RemoteUser"/>
- <data name="Remote address" value="RemoteAddr"/>
- <data name="Remote host" value="RemoteHos"/>
- <data name="Authorization scheme" value="AuthType"/>
- </request-data>
-
- <request-headers title="Request Headers"/>
-
- <servlet-parameters title="Servlet Parameters"/>
+<?cocoon-process type="xsp"?>
+<?cocoon-process type="xslt"?>
+<?xml-stylesheet href="page-html.xsl" type="text/xsl"?>
+
+<xsp:page
+ language="java"
+ xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
+>
-</page>
-
\ No newline at end of file
+ <xsp:logic>
+ static private int counter = 0;
+
+ private synchronized int count() {
+ return counter++;
+ }
+
+ private String normalize(String string) {
+ if (string == null || string.equals("")) return "N/A";
+ else return string;
+ }
+ </xsp:logic>
+
+ <page>
+ <title>First XSP Page</title>
+ <author>
+ <name>Stefano Mazzocchi</name>
+ <address>stefano@apache.org</address>
+ </author>
+
+ <p>Hi, I'm your first XSP page ever.</p>
+
+ <p>I've been requested <xsp:expr>count()</xsp:expr> times.</p>
+
+ <p>The content you are seeing in this page is provided to you
+ by an XML content producer that was compiled into Java bytecode
+ and executed at request time. This allows greater flexibility and
+ ease of use for page programmers without any performance degradation
+ since all XML parsing and such is precompiled and it's avoided at
+ request time.</p>
+
+ <p>Let's show some useful information with expression evaluation...</p>
+
+ <list title="Request Data">
+ <element name="Request method"><xsp:expr>normalize(request.getMethod())</xsp:expr></element>
+ <element name="Request URI"><xsp:expr>normalize(request.getRequestURI())</xsp:expr></element>
+ <element name="Request protocol"><xsp:expr>normalize(request.getProtocol())</xsp:expr></element>
+ <element name="Servlet path"><xsp:expr>normalize(request.getServletPath())</xsp:expr></element>
+ <element name="Path info"><xsp:expr>normalize(request.getPathInfo())</xsp:expr></element>
+ <element name="Path translated"><xsp:expr>normalize(request.getPathTranslated())</xsp:expr></element>
+ <element name="Query string"><xsp:expr>normalize(request.getQueryString())</xsp:expr></element>
+ <element name="Content length"><xsp:expr>request.getContentLength()</xsp:expr></element>
+ <element name="Content type"><xsp:expr>normalize(request.getContentType())</xsp:expr></element>
+ <element name="Server name"><xsp:expr>normalize(request.getServerName())</xsp:expr></element>
+ <element name="Server port"><xsp:expr>request.getServerPort()</xsp:expr></element>
+ <element name="Remote user"><xsp:expr>normalize(request.getRemoteUser())</xsp:expr></element>
+ <element name="Remote address"><xsp:expr>normalize(request.getRemoteAddr())</xsp:expr></element>
+ <element name="Remote host"><xsp:expr>normalize(request.getRemoteHost())</xsp:expr></element>
+ <element name="Authorization scheme"><xsp:expr>normalize(request.getAuthType())</xsp:expr></element>
+ </list>
+
+ <p>Ok. Now that you know how logic can be transformed into content, let's
+ add some juice and mix logic with content generation
+ in a way that allows you to forget about what method is used to generate and
+ handle the content as XML and concentrate on having your work done.
+ Note, how XSP don't allow you to explicitly write something on the response
+ from the logic realm: this is one of the major
+ differences between XSP and other server pages technologies and allows
+ further processing of the produced content, as required, for example, by
+ XSL-transformations.</p>
+
+ <xsp:logic><![CDATA[
+ Enumeration e = request.getHeaderNames();
+ if ((e != null) && (e.hasMoreElements())) { ]]>
+ <p>Here are the request headers...</p>
+ <list title="Request Headers">
+ <xsp:logic><![CDATA[
+ while (e.hasMoreElements()) {
+ String k = (String) e.nextElement(); ]]>
+ <element>
+ <xsp:attribute name="name">
+ <xsp:expr>k</xsp:expr>
+ </xsp:attribute>
+ <xsp:expr>request.getHeader(k)</xsp:expr>
+ </element>
+ }
+ </xsp:logic>
+ </list>
+ }
+ </xsp:logic>
+
+ <xsp:logic><![CDATA[
+ e = request.getParameterNames();
+ if ((e != null) && (e.hasMoreElements())) { ]]>
+ <p>and here the servlet parameters that were passed along
+ with the request...</p>
+
+ <list title="Servlet Parameters">
+ <xsp:logic><![CDATA[
+ while (e.hasMoreElements()) {
+ String k = (String) e.nextElement();
+ String val = request.getParameter(k);
+ String vals[] = request.getParameterValues(k); ]]>
+ <element>
+ <xsp:attribute name="name">
+ <xsp:expr>k</xsp:expr>
+ </xsp:attribute>
+ <xsp:logic><![CDATA[
+ for(int i = 0; i < vals.length; i++) { ]]>
+ <item>
+ <xsp:expr>vals[i]</xsp:expr>
+ </item>
+ }
+ </xsp:logic>
+ </element>
+ }
+ </xsp:logic>
+ </list>
+ }
+ </xsp:logic>
+
+ <p>All right, the first XSP page is over, but you can see the
+ <link href="view-source.xml?filename=page.xml">dynamically syntax highlighted</link>
+ source of this page provided to you by another XSP page.</p>
+
+ <p>Enjoy XSP!</p>
+ </page>
+</xsp:page>
\ No newline at end of file
1.3 +52 -20 xml-cocoon/samples/xsp/view-source.xml
Index: view-source.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/samples/xsp/view-source.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- view-source.xml 1999/11/30 16:30:02 1.2
+++ view-source.xml 2000/01/03 01:37:23 1.3
@@ -7,19 +7,23 @@
<xsp:page language="java" xmlns:xsp="http://apache.org/DTD/XSP/Layer1">
+ <xsp:structure>
+ <xsp:include>java.net.*</xsp:include>
+ </xsp:structure>
+
<xsp:logic><![CDATA[
- private static final String ATTR_NAME_COLOR = "brown";
- private static final String ATTR_VALUE_COLOR = "magenta";
+ private static final String ATTR_NAME_COLOR = "navy";
+ private static final String ATTR_VALUE_COLOR = "navy";
private static final String COMMENT_COLOR = "gray";
- private static final String DELIMITER_COLOR = "green";
- private static final String ELEMENT_COLOR = "darkBrown";
+ private static final String DELIMITER_COLOR = "navy";
+ private static final String ELEMENT_COLOR = "navy";
private static final String ENTITY_REF_COLOR = "navy";
- private static final String PI_DATA_COLOR = "lightBlue";
+ private static final String PI_DATA_COLOR = "navy";
private static final String TEXT_COLOR = "black";
- private static final String CUSTOM_ELEMENT_COLOR = "purple";
+ private static final String CUSTOM_ELEMENT_COLOR = "green";
private static final String XSL_ELEMENT_COLOR = "navy";
- private static final String XSP_ELEMENT_COLOR = "red";
- private static final String XSP_TEXT_COLOR = "blue";
+ private static final String XSP_ELEMENT_COLOR = "green";
+ private static final String XSP_TEXT_COLOR = "red";
protected Element colorize(Node node, Document factory) {
Element element = factory.createElement("pre");
@@ -170,7 +174,7 @@
result.appendChild(
factory.createTextNode(
- "<!-- " + node.getNodeValue() + " -->;"
+ "<!-- " + node.getNodeValue() + " -->\n"
)
);
@@ -229,18 +233,46 @@
<body>
<xsp:logic>
String filename = request.getParameter("filename");
- String filepath = XSPUtil.relativeFilename(filename, request);
+ String resourcename = request.getParameter("url");
+
+ if (filename != null) {
+ String filepath = XSPUtil.relativeFilename(filename, request);
+
+ <h3 style="color:navy; text-align: center">
+ <xsp:expr>filename</xsp:expr>
+ </h3>
+
+ <xsp:expr>
+ this.colorize(
+ this.xspParser.parse(
+ new InputSource(
+ new FileReader(filepath)
+ )
+ ), document
+ )
+ </xsp:expr>
+ } else if (resourcename != null) {
+ URL resource = new URL(resourcename);
+
+ <h3 style="color:navy; text-align: center">
+ <xsp:expr>resourcename</xsp:expr>
+ </h3>
+
+ <xsp:expr>
+ this.colorize(
+ this.xspParser.parse(
+ new InputSource(
+ resource.openStream()
+ )
+ ), document
+ )
+ </xsp:expr>
+ } else {
+ <h3 style="color:navy; text-align: center">
+ Need <em>filename</em> or <em>url</em> parameters to work
+ </h3>
+ }
</xsp:logic>
-
- <h3 style="color:navy; text-align: center">
- <xsp:expr>filename</xsp:expr>
- </h3>
-
- <xsp:expr>
- this.colorize(
- this.xspParser.parse(new FileReader(filepath, filename), document
- )
- </xsp:expr>
</body>
</html>
</xsp:page>
1.1 xml-cocoon/samples/xsp/clean-page.xml
Index: clean-page.xml
===================================================================
<?xml version="1.0"?>
<!-- Author: Stefano Mazzocchi "stefano@apache.org" -->
<!-- Version: $Id: clean-page.xml,v 1.1 2000/01/03 01:37:23 stefano Exp $ -->
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="page-xsp.xsl" type="text/xsl"?>
<page>
<title>First XSP Page</title>
<author>
<name>Stefano Mazzocchi</name>
<address>stefano@apache.org</address>
</author>
<p>Hi, I'm your first XSP page ever.</p>
<p>I've been requested <count/> times.</p>
<p>The content you are seeing in this page is provided to you
by an XML content producer that was compiled into Java bytecode
and executed at request time. This allows greater flexibility and
ease of use for page programmers without any performance degradation
since all XML parsing and such is precompiled and it's avoided at
request time.</p>
<p>Let's show some useful information with expression evaluation...</p>
<request-data>
<string name="Request method" method="Method"/>
<string name="Request URI" method="RequestURI"/>
<string name="Request protocol" method="Protocol"/>
<string name="Servlet path" method="ServletPath"/>
<string name="Path info" method="PathInfo"/>
<string name="Path translated" method="PathTranslated"/>
<string name="Query string" method="QueryString"/>
<int name="Content length" method="ContentLength"/>
<string name="Content type" method="ContentType"/>
<string name="Server name" method="ServerName"/>
<int name="Server port" method="ServerPort"/>
<string name="Remote user" method="RemoteUser"/>
<string name="Remote address" method="RemoteAddr"/>
<string name="Remote host" method="RemoteHost"/>
<string name="Authorization scheme" method="AuthType"/>
</request-data>
<p>Ok. Now that you know how logic can be transformed into content, let's
add some juice and mix logic with content generation
in a way that allows you to forget about what method is used to generate and
handle the content as XML and concentrate on having your work done.
Note, how XSP don't allow you to explicitly write something on the response
from the logic realm: this is one of the major
differences between XSP and other server pages technologies and allows
further processing of the produced content, as required, for example, by
XSL-transformations.</p>
<request-headers/>
<servlet-parameters/>
<p>All right, the first XSP page is over, but you can see the
dynamically syntax highlighted
<link href="view-source.xml?filename=clean-page.xml">source of this page</link>
and its <link href="view-source.xml?filename=page-xsp.xsl">logicsheet</link>
provided to you by another XSP page.</p>
<p>Enjoy XSP!</p>
</page>
1.1 xml-cocoon/samples/xsp/lib-page.xml
Index: lib-page.xml
===================================================================
<?xml version="1.0"?>
<!-- Author: Stefano Mazzocchi "stefano@apache.org" -->
<!-- Version: $Id: lib-page.xml,v 1.1 2000/01/03 01:37:23 stefano Exp $ -->
<?cocoon-process type="xsp"?>
<xsp:page
language="java"
xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
xmlns:servlet="http://apache.org/tags/examples/servlet"
xmlns:util="http://apache.org/tags/util"
>
<page>
<title>First XSP Page</title>
<author>
<name>Stefano Mazzocchi</name>
<address>stefano@apache.org</address>
</author>
<p>Hi, I'm your first XSP page ever.</p>
<p>I've been requested <util:counter/> times.</p>
<p>The content you are seeing in this page is provided to you
by an XML content producer that was compiled into Java bytecode
and executed at request time. This allows greater flexibility and
ease of use for page programmers without any performance degradation
since all XML parsing and such is precompiled and it's avoided at
request time.</p>
<p>Let's show some useful information with expression evaluation...</p>
<list title="Request Data">
<element name="Request method"><servlet:method/></element>
<element name="Request URI"><servlet:requestURI/></element>
<element name="Request protocol"><servlet:protocol/></element>
<element name="Servlet path"><servlet:servletPath/></element>
<element name="Path info"><servlet:pathInfo/></element>
<element name="Path translated"><servlet:pathTranslated/></element>
<element name="Query string"><servlet:queryString/></element>
<element name="Content length"><servlet:contentLength/></element>
<element name="Content type"><servlet:contentType/></element>
<element name="Server name"><servlet:serverName/></element>
<element name="Server port"><servlet:serverPort/></element>
<element name="Remote user"><servlet:remoteUser/></element>
<element name="Remote address"><servlet:remoteAddr/></element>
<element name="Remote host"><servlet:remoteHost/></element>
<element name="Authorization scheme"><servlet:authType/></element>
</list>
<p>Ok. Now that you know how logic can be transformed into content, let's
add some juice and mix logic with content generation
in a way that allows you to forget about what method is used to generate and
handle the content as XML and concentrate on having your work done.
Note, how XSP don't allow you to explicitly write something on the response
from the logic realm: this is one of the major
differences between XSP and other server pages technologies and allows
further processing of the produced content, as required, for example, by
XSL-transformations.</p>
<servlet:headers>
<p>Here are the request headers...</p>
<list title="Request Headers">
<servlet:for-each-header>
<element>
<xsp:attribute name="name">
<servlet:header-name/>
</xsp:attribute>
<servlet:header-value/>
</element>
</servlet:for-each-header>
</list>
</servlet:headers>
<servlet:parameters>
<p>and here the servlet parameters that were passed along with the request...</p>
<list title="Servlet Parameters">
<servlet:for-each-parameter>
<element>
<xsp:attribute name="name">
<servlet:parameter-name/>
</xsp:attribute>
<servlet:parameter-value tag="item"/>
</element>
</servlet:for-each-parameter>
</list>
</servlet:parameters>
<p>All right, the first XSP page is over, but you can see the dynamically syntax highlighted
<link href="view-source.xml?filename=taglib-page.xml">source of this page</link>,
<link href="view-source.xml?resource=resource://org/apache/cocoon/example/servlet-java.xsl">the servlet library logicsheet</link>,
<link href="view-source.xml?resource=resource://org/apache/cocoon/processor/xsp/util-java.xsl">the utility library logicsheet</link>,
all provided to you by another XSP page.</p>
<p>Enjoy XSP!</p>
</page>
</xsp:page>
1.1 xml-cocoon/samples/xsp/page-html.xsl
Index: page-html.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="page">
<xsl:processing-instruction name="cocoon-format">type="text/html"</xsl:processing-instruction>
<html>
<head>
<title><xsl:value-of select="title"/></title>
</head>
<body>
<p><br/></p>
<center>
<table border="0" width="60%" bgcolor="#000000" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<table border="0" width="100%" cellpadding="4">
<tr>
<td width="100%" bgcolor="#c0c0c0" align="right" valign="middle">
<big><big><xsl:value-of select="title"/></big></big>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff">
<xsl:apply-templates/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
<p align="center">
<font size="-1">
Copyright © 1999 <a href="http://xml.apache.org">The Apache XML Project</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="title|author">
<!-- ignore -->
</xsl:template>
<xsl:template match="p">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="em">
<strong><xsl:apply-templates/></strong>
</xsl:template>
<xsl:template match="link">
<a href="{@href}"><xsl:apply-templates/></a>
</xsl:template>
<xsl:template match="list">
<center>
<table border="0" width="90%" bgcolor="#000000" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<table border="0" width="100%" cellpadding="4">
<tr>
<th bgcolor="#e0e0e0" colspan="2" align="right"><xsl:value-of select="@title"/></th>
</tr>
<xsl:apply-templates/>
</table>
</td>
</tr>
</table>
</center>
</xsl:template>
<xsl:template match="element">
<tr>
<td>
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">#f0f0f0</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="bgcolor">#ffffff</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@name"/>
</td>
<td width="100%">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">#f0f0f0</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="bgcolor">#ffffff</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test=".//item">
<ul>
<xsl:for-each select=".//item">
<li>
<xsl:apply-templates/>
</li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon/samples/xsp/page-xsp.xsl
Index: page-xsp.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="page">
<xsl:processing-instruction name="cocoon-process">type="xsp"</xsl:processing-instruction>
<xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
<xsl:processing-instruction name="xml-stylesheet">href="page-html.xsl" type="text/xsl"</xsl:processing-instruction>
<xsp:page language="java" xmlns:xsp="http://apache.org/DTD/XSP/Layer1">
<xsp:logic>
static private int counter = 0;
private synchronized int count() {
return counter++;
}
private String normalize(String string) {
if (string == null || string.equals("")) return "N/A";
else return string;
}
</xsp:logic>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsp:page>
</xsl:template>
<xsl:template match="title|author|link">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="p">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="request-data">
<list title="Request Data">
<xsl:apply-templates/>
</list>
</xsl:template>
<xsl:template match="count">
<xsp:expr>count()</xsp:expr>
</xsl:template>
<xsl:template match="string">
<element name="{@name}">
<xsp:expr>normalize(request.get<xsl:value-of select="@method"/>())</xsp:expr>
</element>
</xsl:template>
<xsl:template match="int">
<element name="{@name}">
<xsp:expr>request.get<xsl:value-of select="@method"/>()</xsp:expr>
</element>
</xsl:template>
<xsl:template match="request-headers">
<xsp:logic><![CDATA[
Enumeration e = request.getHeaderNames();
if ((e != null) && (e.hasMoreElements())) { ]]>
<p>Here are the request headers...</p>
<list title="Request Headers">
<xsp:logic><![CDATA[
while (e.hasMoreElements()) {
String k = (String) e.nextElement(); ]]>
<element>
<xsp:attribute name="name">
<xsp:expr>k</xsp:expr>
</xsp:attribute>
<xsp:expr>request.getHeader(k)</xsp:expr>
</element>
}
</xsp:logic>
</list>
}
</xsp:logic>
</xsl:template>
<xsl:template match="servlet-parameters">
<xsp:logic><![CDATA[
e = request.getParameterNames();
if ((e != null) && (e.hasMoreElements())) { ]]>
<p>and here the servlet parameters that were passed along
with the request...</p>
<list title="Servlet Parameters">
<xsp:logic><![CDATA[
while (e.hasMoreElements()) {
String k = (String) e.nextElement();
String val = request.getParameter(k);
String vals[] = request.getParameterValues(k); ]]>
<element>
<xsp:attribute name="name">
<xsp:expr>k</xsp:expr>
</xsp:attribute>
<xsp:logic><![CDATA[
for(int i = 0; i < vals.length; i++) { ]]>
<item>
<xsp:expr>vals[i]</xsp:expr>
</item>
}
</xsp:logic>
</element>
}
</xsp:logic>
</list>
}
</xsp:logic>
</xsl:template>
</xsl:stylesheet>