Re: Updated soap message normalization draft available
Rich Salz <[email protected]>
| Newsgroups | gmane.text.xml.distributed |
|---|---|
| Message-ID | <[email protected]> |
Attached is a first pass at an XSLT stylesheet that implements the spec. I haven't tested the fault stuff yet. If there is interest, I will do that and develop some test cases (just like other c14n specs). /r$ -- Rich Salz, Chief Security Architect DataPower Technology http://www.datapower.com XS40 XML Security Gateway http://www.datapower.com/products/xs40.html XML Security Overview http://www.datapower.com/xmldev/xmlsecurity.html
soap-n11n.xsl
(text/xml, 2.6 KB)
<?xml version="1.0"?>
<!-- vi: set sw=2 ts=8 et: -->
<!--
An XSLT implementation of SOAP message normalization.
Placed in the public domain by the author, Rich Salz.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:env="http://www.w3.org/2002/06/soap-envelope">
<xsl:output method="xml"/>
<xsl:variable name="ultimate"
select="'http://www.w3.org/2002/06/soap-envelope/role/ultimateReceiver'"/>
<xsl:variable name="ns" select="'http://www.w3.org/2002/06/soap-envelope'"/>
<xsl:template match="env:Fault|env:Code|env:Subcode|env:Value|env:Reason|env:Text|env:Node|env:Role" mode="Fault">
<xsl:copy>
<xsl:copy-of select="@*|*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/env:Envelope/env:Body/env:Fault">
<xsl:apply-templates mode="Fault"/>
</xsl:template>
<xsl:template name="Normalize-Attribute">
<xsl:choose>
<xsl:when test="namespace-uri() = $ns and local-name() = 'mustUnderstand'
and . != '0' and . != 'false'">
<xsl:attribute name="{'mustUnderstand'}">true</xsl:attribute>
</xsl:when>
<xsl:when test="namespace-uri() = $ns and local-name() = 'relay'
and . != '0' and . != 'false'">
<xsl:attribute name="{'relay'}">true</xsl:attribute>
</xsl:when>
<xsl:when test="namespace-uri() = $ns and local-name() = 'role'
and . != '' and . != $ultimate">
<xsl:copy/>
</xsl:when>
<xsl:otherwise>
<xsl:copy/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="Copy-Header">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:call-template name="Normalize-Attribute"/>
</xsl:for-each>
<xsl:copy-of select="child::node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/env:Envelope/env:Header" mode="Headers">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="child::*">
<xsl:call-template name="Copy-Header"/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
<xsl:template match="/env:Envelope/env:Body">
<xsl:copy>
<xsl:copy-of select="@*|*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/env:Envelope">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:if test="count(env:Header/child::*) > 0">
<xsl:apply-templates select="env:Header" mode="Headers"/>
</xsl:if>
<xsl:apply-templates select="env:Body"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>