Project

General

Profile

Feature #1586

Velocity Servoy Plugin server xml response format

Added by Anton Serov 9 months ago. Updated 9 months ago.

Status:
Rejected
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Start date:
08/24/2023
Due date:
% Done:

0%

Estimated time:
Browser (if web client):

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

#1

Updated by Patrick Talbot 9 months 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…

Also available in: Atom PDF