The XML declaration part of the response message is lost

Document ID : KB000099966
Last Modified Date : 04/06/2018
Show Technical Document Details
Question:
Uses "Add or Remove XML Element (s)" assertion. 
Result: XML Declaration (<?xml version="1.0" encoding="UTF-8" ?>)  was deleted. 

Is this a bug? 
The customers want that XML Declaration will not be erased.



01. Create new service in Policy Mnagaer.
02. import test.xml.
03. Run the servcei.


Souece XML:
<?xml version="1.0" encoding="UTF-8" ?>
<foods>
  <food>
    <name>banana</name>
    <color>yellow</color>
  </food>

</foods>

Target XML:
<foods>
  <food>
    <saize>100</saize><name>banana</name>
    <color>yellow</color>
  </food>

</foods>
Environment:
CA API Gateway - 8.x
CA API Gateway - 9.0
CA API Gateway - 9.1
CA API Gateway - 9.2
CA API Gateway - 9.3
Answer:
It is not bug. 
It is on based on design. 
Because, the declaration is never the part of the actual content.

Also, in order to include the XML declaration part, it is possible to add it to an XML type variable with Set Context Variable assertion.

"Set Context Variable” setting example:
Data Type : Message 
Content-Type : Text/xml; charset=utf8 
Expression: 
<?xml version="1.0" encoding="UTF-8" ?> 
${[ responce of Add or Remove XML Element(s).mainpart}