How can I remove a specific namespace in an XSL transform?

Posted on 2008-11-16
Last Modified: 2013-11-18

Getting stuck on an XSL transform I am writing and wonder if anyone can help...

I have included all the stages of the transform below.

The idea is that input doc is transformed so the wsse:Security section is completely removed and custom header tags exist in its place.

As you can see in the output doc below, it almost completely removes all traces of the wsse tags but leaves in the xmlns:wsse namespace declaration in the soapenv:Envelope tag. How can I also remove this in the transformation? Do I need to setup the identity transform in such a way as to not copy this (if so how can I do this?) Or... is there a better way?

One of the many things I tried was using exclude-result-prefixes but for some reason that has no effect.

Many thanks,

Input doc:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="" xmlns:wsse="">

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:test="" xmlns:soapenv="">
      <xsl:output method="xml" indent="yes"/>
      <!-- Replace Security header with Context elements -->
      <xsl:template match="/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='Security']">
            <!-- Construct the context data in the message -->
                  <xsl:value-of select="'a'"/>
                  <xsl:value-of select="'b'"/>
                  <xsl:value-of select="'c'"/>
      <!-- Identity transform  -->
      <xsl:template match="@*|node()">
                  <xsl:apply-templates select="@*|node()"/>
Output doc:
(the xmlns:wsse namespace declaration should NOT exist in the message below).

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv=""
            <test:a xmlns:test="">a</test:a>
            <test:b xmlns:test="">b</test:b>
            <test:c xmlns:test="">c</test:c>
Question by:alandp
    LVL 5

    Expert Comment

      exclude-result-prefixes = NCNames

    Author Comment

    Thanks for your response, I had tried

    <xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:test="" xmlns:soapenv="" exclude-result-prefixes = "wsse">

    but it still remained.

    LVL 5

    Accepted Solution

    the xsl:copy forces it to be added (didn't knew that :) ) as i replaced the copy template with this, it was gone

          <!-- Identity transform  -->

          <xsl:template match="*">
                <xsl:element name="{name()}">
                      <xsl:for-each select="@*">
                            <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
                      <xsl:apply-templates select="*" />

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now