This scenario illustrates how to modify the StatusCode and Reason elements in an HTTP Response. The XSLT in this example makes the following updates:
The following sample input documents are used for this scenario:
HTTP Response
<?xml version="1.0" encoding="UTF-8"?>
<HTTPResponse>
<ResponseLine>
<Version>HTTP/1.1</Version>
<StatusCode>503</StatusCode>
<Reason>Service Unavailable</Reason>
</ResponseLine>
<Headers>
<Header name="Date">Thu%2C%2016%20Sep%202010%2010
%3A57%3A52%20GMT</Header>
<Header name="Server">IBM_HTTP_Server</Header>
<Header name="Content-Type">text%2Fhtml%3Bcharset%3DUTF-8</Header>
<Header name="Content-Language">en-US</Header>
</Headers>
<Cookies>
<Cookie name="PD-S-SESSION-ID">
<Content>2_orQUNJCbjdxqIEdDPMXj31UiHMXuU3hRCUtpN7xe6J1xZhxt0</Content>
<Path>/</Path>
<Domain>domainA.com</Domain>
<Expires>Wed, 09 Jun 2021 10:18:14 GMT</Expires>
<Secure>1</Secure>
<HTTPOnly>0</HTTPOnly>
</Cookie>
</Cookies>
</HTTPResponse>
XSLT Rules
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!--Firstly, strip any space elements -->
<xsl:strip-space elements="*" />
<!--
Perform a match on the root of the document. Output the required
HTTPResponseChange elements and then process templates.
-->
<xsl:template match="/">
<HTTPResponseChange>
<xsl:apply-templates />
</HTTPResponseChange>
</xsl:template>
<!--
Do nothing to the Version
-->
<xsl:template match="//HTTPResponse/ResponseLine/Version" />
<!--
If the original StatusCode is 503 then update the
StatusCode to 501.
-->
<xsl:template match="//HTTPResponse/ResponseLine/StatusCode">
<xsl:choose>
<xsl:when test="503">
<StatusCode>501</StatusCode>
</xsl:when>
</xsl:choose>
</xsl:template>
<!--
Update the Reason to match the StatusCode change.
-->
<xsl:template match="//HTTPResponse/ResponseLine/Reason">
<xsl:choose>
<xsl:when test="'Service Unavailable'">
<Reason>Not Implemented</Reason>
</xsl:when>
</xsl:choose>
</xsl:template>
<!--
Do nothing to the Headers.
-->
<xsl:template match="//HTTPResponse/Headers" />
<!--
Do nothing to the Cookies.
-->
<xsl:template match="//HTTPResponse/Cookies" />
</xsl:stylesheet>
In this scenario, the following XML document is output from the XSL transformation. This document outlines changes for WebSEAL to perform on the original HTTP response.
<?xml version="1.0" encoding="UTF-8"?>
<HTTPResponseChange>
<StatusCode>501</StatusCode>
<Reason>Not Implemented</Reason>
</HTTPResponseChange>