Tuesday, July 30, 2013

XML Schema Refactoring Tools

Liquid XML Studio XSD Editor includes a range of XML Schema refactoring tools. This can be extremely useful when working with XML Schema, especially if you have generated an XSD using XML source data with the inferring tools.

Rather than having to edit your XSDs manually, the Refactoring menu provides automated tools for making global changes to your element and attribute definitions. Such amendments can alter the way in which the structural definitions within your XSDs are organised, making them accessible for reuse.

XSD Refactoring Tools

Friday, July 19, 2013

Adding xml to an ‘Any’ Element

Sometimes you will need to add an XML fragment into another XML document. A good example of this would be while constructing a SOAP request.

A simple solution to this would be to just build a string value and use the ToXml() method to add the xml fragment from your object model.

E.g. This C# example shows inserting an XML message part into a OpenTravel webservice SOAP request:

string soap = "<?xml version=\"1.0\" encoding=\"utf-8\"?><SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Body><tns:OTA_VehLocSearch xmlns:tns=\"http://www.opentravel.org/OTA/2003/05\" xmlns=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";

soap = soap + liquidObj.ToXml();

soap = soap + "</tns:OTA_VehLocSearch></SOAP-ENV:Body></SOAP-ENV:Envelope>";

 

However, sometimes you will have the entire structure in your Liquid XML generated Object Model, where the above XML message part is represented as an ‘Any’ element within the XSD. In the scenario, you will need to use the ‘Element’ object within your code.

E.g.  This C# example shows inserting an XML message part as a generic Element object:

Envelope env = new Envelope ();

Element elm = new Element();

elm.FromXml(liquidObj.ToXml());

env.AnyElement.Add(elm);

env.ToXml();



From Knowledge Base Article:
Adding xml to an ‘Any’ Element