Feature #1586
Velocity Servoy Plugin server xml response format
0%
Description
Hi
Is there way to control XML serialization process for Response contextObject? (ResponseObject = plugins.Velocity.createResponse(contextObject, [template], [inline]))
We need to serialize Javascript object properties to XML attributes (Not to XML Elements)
We also need to remove "context" root XML element.
Current XML for Javascript object:
<context>
<JMF>
<type>SubmissionMethods</type>
<version>2.0</version>
</JMF>
</context>
Desired XML Response:
<JMF type="SubmissionMethods" version="2.0">
</JMF>
History
Updated by Patrick Talbot over 1 year ago
- Tracker changed from Defect to Feature
- Status changed from New to Rejected
There’s no way to control the xml serialization process, which is using a simple translation from JavaScript object to JSON to XML, based on the org.json library.
However, I suppose you could create a xml template which would contain something like this:
var template = '\
<JMF #if($type) type="$type" #end #if($version) version="$version" #end>\
</JMF>';
Then push the needed variable in your context:
var context = { type: "SubmissionMethods", version: "2.0" };
var ResponseObject = plugins.Velocity.createResponse(context, template);
A bit tedious depending on the size and number of elements/attributes you need, but that would give you the result you want…