Frederick,
I think, handling this requirement in XSLT is difficult. In Graphical mapping, it's not possible. Please use below Java Mapping.
package com.javaMapping; import java.io.*; import com.sap.aii.mapping.api.*; public class WellformedXML_JavaMapping extends AbstractTransformation { @Override public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException { try { InputStream inputstream = transformationInput.getInputPayload().getInputStream(); OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream(); // a) Copy Input content to String byte[] b = new byte[inputstream.available()]; inputstream.read(b); String inputContent = new String(b); // b) Replace logic here. Edit StartTag and EndTag, below. FYI. Assuming namespace-alias ns2 will be 3 characters (3 dots). inputContent = inputContent.replaceAll("<...:despatchAdvice>", "StartTag").replaceAll("</...:despatchAdvice>", "EndTag"); outputstream.write(inputContent.getBytes()); } catch (Exception exception) { getTrace().addDebugMessage(exception.getMessage()); throw new StreamTransformationException(exception.toString()); } } }