Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add fields to XML document without making the recipient change his/her schema

Tags:

xml

xsd

I have an application which sends same XML document to many systems. Now one of the systems wants to get one field extra. The question is how can I add the field to the document and send it to all system without breaking their process. in a different wor, how can I make other systems to ignore the added field?

like image 736
hgaarous Avatar asked Sep 02 '25 02:09

hgaarous


1 Answers

You can't do this without breaking existing recipients unless the recipients have been designed with this kind of change in mind.

It's very common for XML systems to specify a policy of "if you don't understand an element, then ignore it", and if you have such a policy, and people follow it, then adding new optional fields becomes easy. But if no such policy is in place, or if it hasn't been tested in anger, then adding fields risks breakage.

At the level of the schema, new fields can be added as optional elements or attributes. If the extensions are customisations for a particular client or group of clients, then you might want to consider putting the extra elements or attributes into a different namespace so they don't clash with extensions invented by someone else. This also allows you to exploit XSD schema wildcards which make any content valid provided it is in a different namespace.

like image 103
Michael Kay Avatar answered Sep 05 '25 09:09

Michael Kay