Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WBRIDGE and version 7.10.0
Div
Classe2e-refDiv

Otp
Floatingfalse
 

Rp
Rde
Syntax
Code Block
languagenone
set anObject = aBlob.xmlToClass();
Semantics

The operation takes an XML buffer as blob (aBlob) and tries to map the XML document to anObject. If this is not possible, an error is raised (e.g. XML parser errors, invalid mappings, etc.).

By default the following mapping rules apply:

  • XML attributes are mapped to class attributes.
  • XML elements are mapped to class associations ends.

These default rules can be overridden by using <<XMLElement>>, <<XMLAttribute>> , and <<XMLCharacters>> stereotypes on UML class attributes and UML association ends. More about these mapping rules, stereotypes and tagged values (e.g. for number and date & time formatting) can be found in section XML - UML Class Mapping.

Noteinfo
iconfalse

Frequently, an XML document is given as a string instead of a blob. In such cases, it is possible to apply xmlToClass() to a string as well. For details see xmlToClass Strings.

SubstitutablesaBlobCan be any variable or object attribute having the type Blob.
anObjectTarget object, can be any object.
Error CodesFind the related error codes on Log Errors of domain XMLLM.
XMLLM/3The native XML parser reported a fatal error during parsing.
Read more on Troubleshooting XML - UML Class Mapping for more information if you cannot resolve such errors.
Examples
Code Block
languagenone
set myAddress = addressASXMLDocument.xmlToClass();

 The following action script creates an object of type Address. An output object node named myAddress of type Address needs to be defined in the activity diagram.

Code Block
languagenone
create myAddress;
set myAddress = addressASXMLDocument.xmlToClass();

Below, a sample XML document is shown to illustrate the mapping executed by xmlToClass() operation. The XML document is mapped to an instance of Address as depicted in the class diagram:

Code Block
languagehtml/xml
 
	<myAddress id="myAddressID"> 
		<street>Lautengartenstr. 12</street> 
		<city>Basel</city> 
	</myAddress>	

Note, that the XML element myAddress is of type Address. This type has the UML attribute id, which corresponds to the XML attribute id. Additionally, the XML elements street and city are mapped to the association ends city respectively street. Both are having the type String.

...