Exclude XML namespace prefixes in XSLT
I've been working on a PECI integration that sends an XML vendor to the file. Today I received the requirement: "could you remove the namespace?"
My answer: Yup!
The problem¶
Let's take a PECI XML -> XML file transformation as an example. The resulting XML file will have the following at the top:
XML
<?xml version='1.0' encoding='UTF-8'?>
<Person xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:peci="urn:com.workday/peci">
The xmlns:xs and xmlns:peci namespaces are causing downstream issues and need to be removed.
The solution¶
To remove these on the output, add exclude-result-prefixes="ns1 ns2" to the xsl:stylesheet tag attributes.