cx:namespace-delete — Delete namespace declarations.


<p:declare-step type="cx:namespace-delete" xmlns:cx="">
     <p:input port="source"/>
     <p:output port="result"/>
     <p:option name="prefixes"/>                                   <!-- ListOfStrings -->


This step aggressively removes all of the namespaces identified by the specified prefixes from the document. The prefixes must be in-scope at the point where the cx:namespace-delete element occurs.

Consider this document:

<doc xmlns:ns1=""
  <para ns1:attr="value">This document has
unspecified semantics with respect to
<ns1:item>{ns1:foo}</ns1:item> and

If the following step is used to remove the “ns1” prefix,

<cx:namespace-delete xmlns:ns1=""

the resulting document will be:

<doc xmlns:ns2="">
  <para attr="value">This document has
unspecified semantics with respect to
<item>{ns1:foo}</item> and

Observe that the namespace declaration has been stripped off both elements and attributes. If prefixes occur in places, such as attribute values or text content, not “visible” to the XML specification, they are not changed.


Removing namespace declarations from attributes can introduce well-formedness problems. For example, if the “para” element in the example had an attr attribute in no namespace, deleting “ns1” would leave two attributes with the same name on the element. This is not well-formed and the step would fail.

This problem can be addressed by first deleting the offending attributes, perhaps like so:

<p:delete xmlns:ns1=""