I have data available in the form of Structs and Arrays.I need some design pattern advice, which I can use to model this situationinto corresponding Coldfusion Components.Here is the data definitionI have objects likeHotelApartmentBusEach object has it's attributes and images. Images have also different types likethumbnails, gallery etc.Attributes may be simple or complexSimple Attributes like: name, code, id etcAnd complex attributes are themselves objects which have it's own Attributes and Images.The second part is Customers. Our customers receive these objects as XML export files. Each customer has it's own requirements. For example some wantone kind of attributes and other want other attributes. Some want that one type of images should be exported and some want all image types should be exported.
Is there a design pattern or technique in Coldufsion/Java for serializing objects differently depending on customer's desires?
java;design patterns;coldfusion
Typically what I would do in that situation is to have one XML definition for each of your objects such as Hotels, Apartments and Buses. Choose the simplest possible definition, it will only be known to you. Example:<hotel id=1> <property1></property1> <image type=X></image> <image type=Y></image> etc.</hotel>The objects you would like to export will first be serialized to XML files, given your definitions.Then, you have to associate for each customer an XSLT file that will be able to transform your private XML file to the XML format desired by the customer. Given a source XML, with XSLT you will able to generate destination XML files with whatever attributes or elements the customer wants. Basically, here's your process for generating XML files compatible with each customer:Serialize your objects to one or more XML filesGet the XSLT file associated to your customerApply the XSL transformation to your source XML file(s) to get the destination XML file(s)The main advantage of this technique is that you have your own XML format, no one knows about it except you, and as such, you are not entitled to any specific/proprietary customer XML format.It's more of a technique than a design pattern, but I guarantee you it's a good one.Finally, it's been a long time since I've done some XSLT, but if you are not familiar, check the MDN reference website.