Mapping to/from XML and XSD
The platform allows you to map your own tree data structures to/from XML (for data) and XSD (for schemas). Since the full capabilities of XML/XSD are extensive, there are three mapping modes available here: full, shorthand and hybrid.
- Abbreviated mapping represents records as sequences (or any lists xsd:all) of elements, and fields with values as attributes or elements with simple content. The order follows directly from the order in the platform schema. The namespace is empty or configured once at the block level. This approach allows for quick prototyping or creating uncomplicated schemas for simple data.
- Full mapping, requires for each record and field to specify a XML(XSD) mapping annotation, in which we specify the name and space of the XML element/attribute, the type of the so-called XSD "partition" or other details of the mapping (e.g., a list of simple values, textual content, selection of one of the possibilities, type derivations, etc.), mark the local or global typing, as well as the exact order of the children, usually different from that resulting from the schema alignment of the platform. Elements not indicated in this order will then be ignored from an XML point of view.
Specifying all this information every time would be impractical, so there is also a hybrid mode, in which some parts of the tree are handled in simple mode and others in full mode (as long as XML annotations are present).
Mapping to/from XML/XSD is used, for example, in the following places in the platform:
- a block for writing to typed XML, in which you must first load the XSD file (or files with external references) and on this basis prepare a template of the main document and its fragments-list,
- the simple XML read and write block, in which you can use XML detailed mapping fragments or stay with the simple mode,
- SOAP Request and Response blocks, in which the data schema is converted into fragments of the service's WSDL specification,
- the external SOAP service call block, in which we load WSDL (from disk or the network) and, after indicating the operation, prepare templates for the service's input data (to be filled in before the call) and possibly output data (substituted as a result of a query-type request).
Due to the wide issue that is XSD when it comes to getting acquainted with the full capabilities of XSD mapping, you should familiarize yourself with external XSD documentation.
The XML mapping annotation is displayed in the schema tree in the form of an icon symbolizing XML <> and an abbreviated description, hinting at what we are dealing with (special packaging, element or attribute). For clarity, the name is displayed only if it is different from the one in the platform's schema. A similar abbreviation takes place for the XML namespace - we will only see it if it is different from the parent. Of course, once a node is selected, all details are available in the Details tab.
Interestingly, not only the data structure is transferred between the XSD and the platform schema description, but also the descriptions, regular expressions narrowing the data, lists of allowed values and single option restrictions (XmlSchemaChoice). This makes it possible to directly transfer the schema to the random data generator block and get test data that meets most of the constraints of a given XSD.