XML Format
It helps in customizing the xml details of a <property> in terms of attributes, child elements, prefixes and their wrappers.
Possible Location
Note:
A default XML format is always available for all the properties configured in the ZSPEC.
A default XML format is always available for all the properties configured in the ZSPEC.
Attributes
Name | Type | Description |
---|---|---|
name | String | Name of the property in XML format. |
namespace | String | Namespace of the XML, if required. |
prefix | String | The prefix, which has to be added to the XML tags. |
attribute | Boolean | Decides whether the property has to be made as an attribute in the XML.
|
wrapped | Boolean | Represents whether a wrapper element is required for a collections property.
|
Example
Consider that the below JSON object is the response-body of the GET operation of trips resource.
copysample response: { "trips": [ { "trip_name":"Spring Break - John Doe", "destination": "Bali", "start_time": "2023-11-13T17:30:00", "end_time": "2023-11-17T22:30:00", "no_of_days": 4 }, { "trip_name":"christmas Break - Diana Williams", "destination": "London", "start_time": "2023-12-20T21:30:00", "end_time": "2023-12-28T09:30:00", "no_of_days": 7 } ] }
Now, you want the XML format of this response. The default XML representation of it is given as follows,
copydefault XML format: <root> <trips> <trip_name>Spring Break - John Doe</trip_name> <destination>Bali</destination> <start_time>2023-11-13T17:30:00</start_time> <end_time>2023-11-17T22:30:00</end_time> <no_of_days>4</no_of_days> </trips> <trips> <trip_name>Christmas Break - Diana Williams</trip_name> <destination>London</destination> <start_time>2023-12-20T21:30:00</start_time> <end_time>2023-12-28T09:30:00</end_time> <no_of_days>7</no_of_days> </trips> </root>
But, you want to customize the xml format as shown below.
copy<ns:trips-array xmlns:ns="http://example.com/namespace"> <ns:trip trip_name="Spring Break - John Doe" destination="Bali" no_of_days="4"> <start_time>2023-11-13T17:30:00</start_time> <end_time>2023-11-17T22:30:00</end_time> </ns:trip> <ns:trip trip_name="christmas Break - Diana Williams" destination="London" no_of_days="7"> <start_time>2023-12-20T21:30:00</start_time> <end_time>2023-12-28T09:30:00</end_time> </ns:trip> </ns:trips-array>
Write the xml-format under the corresponding <property> as shown here to achieve this requirement.
copy<structure> <property name="trips" type ="collections"> <xml-format name="trips-array" namespace="http://example.com/namespace" prefix="ns" wrapped="true"> <structure> <property type="map"> <xml-format name="trip" prefix="ns" /> <structure> <property name="trip_name" type="string"> <xml-format attribute="true"></xml-format> </property> <property name="destination" type="string"> <xml-format attribute="true"></xml-format> </property> <property name="no_of_days" type="string"> <xml-format attribute="true"></xml-format> </property> <property name="start_time" type="datetime"/> <property name="end_time" type="datetime"/> </structure> </property> </structure> </property> </structure>
Last Updated 2025-05-30 16:54:59 +0530 +0530
Yes
No
Send your feedback to us
Skip
Submit