The following operations and components are using this information:
SOAP Adapter and SOAP Services exchanging document style/literal encoded messages.
- Blob operation:
- String operation:
- Any type operation:
Controlling the Mapping by Stereotypes
Stereotypes control how UML class properties (attributes and association ends) are serialized to an XML Document. If no stereotype is assigned, the following default rules apply for mapping XML to UML classes (
- XML attributes are mapped to class attributes.
- XML elements are mapped to class associations ends.
- The XML root element is named according to the definitions in the service composite, tagged value Class To XML Default Root Name.
The following stereotypes are available:
(Description see below)
|<<XML>>||Set this basic stereotype on class level to be able to apply the stereotypes listed below to the attributes.||xmlNamespace |
|<<XMLElement>>||UML properties are mapped to XML elements.||xmlNamespace |
UML properties having a simple type are mapped to XML attributes.
|<<E2EAttribute>>||This stereotype can be used to specify an order for the generation of XML elements.||order|
|<<XMLNamespace>>||UML properties having a simple type are mapped to XML namespaces.|
The prefix of the namespace is given by the property name. If the same namespace is declared more than once, the runtime will suppress namespaces further down the XML hierarchy, if prefix and namespace are identical. If not, the xUML Runtime will throw an exception.
|<<XMLCharacters>>||UML properties having a simple type are serialized as a character stream.||xmlFormat|
|Tagged Value||Level||Description||Allowed Values|
Bridge 7 Specify which name to assign to the XML root element upon serializing. This setting can be overridden by using XML composer options as described on classToXML() Operation.
Try to use name and namespace defined on the class by the <<XML>> stereotype. Fallback to Variable Name if not provided (default).
Use static name and namespace of the class as name of XML root element.
Use the name of the reference (object/variable) as name of XML root element.
|xmlNamespace||Class||Specify the XML namespace.||a valid namespace|
|xmlElementName||Class||Specify the name of the XML root element.||a valid element name|
Specify whether the XML contains attributes that are serialized as character stream (attributes with stereotype <<XMLCharacters>>, see also Controlling the Mapping by Stereotypes).
|true||XML contains serialized attributes.|
|false||XML does not contain serialized attributes (default).|
|isOrdered||Class||Specify whether the class attributes should be serialized to XML using the order tag that has been specified on the attributes.||true||Serialize in order of order tags from the attributes.|
|false||Serialize in order of attributes on class.|
Each XML attribute and element may have its own namespace. If the tagged value contains an URI, the runtime will automatically generate a unique prefix.
Example: A tagged value xmlNamespace = "
|a valid xlmns syntax|
Depending on this tagged value, XML elements or attributes may not be qualified by a namespace prefix even if they have one.
The element or attribute must always be qualified by a namespace prefix. Default for XML elements.
|unqualified||No namespace prefixes are allowed (for details see http://www.w3.org/TR/xmlschema-0/#NS). Default for XML attributes.|
If numbers and date/time types are parsed or composed, the XML parser respectively composer expects simple date types following the XML schema specification. However, legacy XML documents may contain different number and date/time formats. In this case, the tagged value xmlFormat may hold a format string. If numbers are parsed or composed use the format strings defined in section Number Formatting. If date/time expressions must be parsed or composed, use the format strings defined in Date and Time Formatting.Use xmlFormat = "CDATA" together with stereotype <<XMLElement>> to compose strings as CDATA with
|a valid format string (see Number Formatting or Date and Time Formatting)|
|CDATA||compose string as CDATA|
By default, UML properties that are NULL are not serialized into XML documents. However, if it is necessary to do so, isNillable must be set to true. In this case, the UML properties being NULL will look like:
|true||serialize NULL properties|
|false (default)||do not serialize NULL properties|
|order||Attribute||Use this tagged value of <<E2EAttribute>> to specify the order in which the XML elements will be generated to the XML document.||a valid float|
The behavior of XML serialization is not always self-explanatory but a consequence of the definition of arrays in XML schema.
The following table shows the behavior of XML serialization for the following class containing an array:
|All values are present.|
|The second value (A2) is NULL and isNillable=false.|
|The second value (A2) is NULL and isNillable=true|
|The array is NULL.|
|The array is empty.|
|All elements are NULL and isNillable=false.|
|All elements are NULL and isNillable=true.|
|classToXMLDefaultRootName="Default" and xmlElementName="anotherClass".|
|classToXMLDefaultRootName="Type Name" and xmlElementName="anotherClass".|
|classToXMLDefaultRootName="Variable Name" and xmlElementName="anotherClass".|
The following example shows how to convert an XML data structure with mixed content to an UML class.
Suppose the following XML data structure with two elements street and city is given:
The class diagram below illustrates how to map the content of XML element street ("13, Coal Street") and the value of its attribute id ("4711-1") to a class structure:
To map XML element street and its attribute id, you need a dedicated class as a container. In this example, this is class StreetElement. XML attribute id of element street is mapped to class attribute id of UML class StreetElement via matching names. The content of the XML element street is mapped to the class attribute that has stereotype <<XMLCharacters>>. In this example this is text_value.
Class StreetElement must have stereotype <<XML>> and tagged value isMixed set to true because it contains the serialized attribute text_value (also see explanation of tagged value isMixed ).
Containter StreetElement is associated to the main address class. The name of the association end (street) must match the name of the XML element. Associated class StreetElement is only a container for the street element and its name is not relevant for the mapping.
If the XML element contains attributes, which should not be mapped to UML class attributes, an association to a base type can be used. The example shows this for element city . The content of the element ("New York, NY 10017, USA") will be available in city (accessible as attribute of the instantiated class Address2Example1). As the id attribute cannot be mapped, it will be discarded when executing
If an object of class Address2Example1 was serialized back in a SOAP response, the SOAP message would read:
The same result could be obtained with the following class diagram:
You have the flexibility to map XML structures in different ways. You can define very compact class diagrams for simple XML structures, but you have also the possibility to map complex XML data structures graphically.