166
Chapter 5 XML Digital Signatures
Vendor Toolkits); otherwise, you might discover that you are actually signing
something different from what you think you are signing.
Using XSLT to Transform a Document
As powerful as XPath is, it is a fairly passive mechanism. Data is or is not allowed
to pass, but XPath does nothing to the data.The optional XSLT algorithm pro-
vides the ability to actively manipulate the data on its way to getting signed.The
basic steps are the same as applying XPath: Define a Transform element that will
use the XML style sheet language (XSLT) to manipulate the data. In order to do
this, you define a style sheet that will provide the desired processing to the input
data.The XSLT language is worthy of study on its own; it provides a rich syntax
for defining the manipulations that you want to apply. In this section, we look
only at a simple example, the same problem that we have addressed using XPath:
stripping out all but the location element from the weather report data.
A simple style sheet that can accomplish this task is shown in Figure 5.14.
Figure 5.14 A Simple Style Sheet for Obtaining Only the Weather Station
Locations
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="no" method="xml" />
<xsl:template match="document/header">
</xsl:template>
<xsl:template match="document">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="content/weather">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="location">
<xsl:apply-templates />
</xsl:template>
www.syngress.com
Continued