Skip to main content
Skip table of contents

xmlToClass() Operation for Blobs

Syntax

NONE
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.

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() for Strings.

Substitutables

aBlob

Can be any variable or object attribute having the type Blob.

anObject

Target object, can be any object.

Error Codes

Find the related error codes on Log Errors.

XMLLM/3

The 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

NONE
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.

NONE
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:

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.

Example File (Builder project E2E Action Language/XML):

<your example path>\E2E Action Language\XML\uml\xmlSimpleConversions.xml
<your example path>\E2E Action Language\XML\uml\xmlComplexConversions.xml

XML Parsing Options (Validation against a Schema)

The optional parameter of xmlToClass() of type XMLOptions offers various parameters to control schema and DTD location and validation:

Figure: XML Parse Options Class

Be aware that by default, schemas are parsed, but documents are not validated against them. Set the validation attribute to true if you want to enforce validation beyond well-formedness. For example, assume that you want to validate your document against a schema called CustomerData.xsd having the namespace http://example.com/customer. Then, the following xmlOption attributes have to be set:

externalSchemaLocation ="http://example.com/customer CustomerData.xsd";
validation = true;

If the XML document refers a schema file (.xsd) with filename (and optional path), it is sufficient to put the schema file into the folder <e2e data>/resource. The E2E Bridge will automatically load this one instead of the specified. Using the administration interface of the Bridge, it is possible to load XML schemas into this folder remotely by using the following dialog:

Figure: Uploading XML Schemas

Refer to Deploying and Managing Resources in the Bridge User's Guide for more information on uploading of resources to the E2E Bridge.

If the XML document refers no schema or you would like to provide another than the referred one, use the XMLParseOptions structure and set externalSchemaLocation (or externalNoNamespaceSchemaLocation) accordingly. As above, missing or relative paths will be redirected to the folder <e2e data>/resource. The same applies also for validating against DTDs. Be aware that validation is turned off by default (see option validation below).

Related Documentation:

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.