www.pudn.com > chap8.rar > shopping.xslt


<?xml version="1.0" encoding="UTF-8"?>

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

<!--
*********************************************************************
** global.sessionID : Used for URL-rewriting to implement
** session tracking without cookies.
******************************************************************-->
<xsl:param name="global.sessionID"/>

<!-- This stylesheet produces XHTML -->
<xsl:output method="xml" indent="yes" encoding="UTF-8"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

<!--
*********************************************************************
** This template produces the skeletal XHTML document.
******************************************************************-->
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Shopping Example</title>
</head>
<body>
<!-- Create a form for this page -->
<form method="post">
<!-- Specify the form action="..." attribute -->
<xsl:attribute name="action">
<!-- Encode the session identifier into the URL
to enable session tracking. -->
<xsl:call-template name="encodeURL">
<xsl:with-param name="url" select="'/chap8/shopping'"/>
</xsl:call-template>
</xsl:attribute>

<h1>Shopping Example</h1>
...remainder of page omitted
</form>
</body>
</html>
</xsl:template>

<!--
*********************************************************************
** This template performs URL rewriting if the $global.sessionID
** variable has been set. The caller must pass in a 'url' parameter.
******************************************************************-->
<xsl:template name="encodeURL">
<xsl:param name="url"/>

<!-- output the url. -->
<xsl:value-of select="$url"/>

<!-- If $global.sessionID is set, also
output ";jsessionid=0000000" -->
<xsl:if test="$global.sessionID">
<xsl:text>;jsessionid=</xsl:text>
<xsl:value-of select="$global.sessionID"/>
</xsl:if>
</xsl:template>

</xsl:stylesheet>