Table of contents

Official Content

How and where do you define the structure of a Structured Data Type (SDT) object?

By using the SDT Editor.

While creating a Structured Data Type (SDT) object, you may define a multilevel structure, similar to the Transaction's structure. Each level can have one or more members. These members may be classified into:

  • Simple Elements
  • Compound Elements (also composed of other elements).

In this article you will find:

Simple Elements

While defining a member in a Structured Data Type (SDT) object design, you must specify the following:

  • Name property: to identify the member. There cannot be two elements defined with the same name.
  • Data Type property: you may select between GeneXus basic types (Numeric, Character, etc), Domains, or another already defined SDT.
  • Is Collection property: to indicate whether the element has multiple instances (it can be repeated) or not. It has two possible values: True or False.

Look at the following image:


XML Properties

While working with SDTs you can define some properties related to each kind of element, in order to have control over the SDT serialization to different formats, such as XML. When working with a simple element (a member) you will see the following XML properties:

  • XmlType
  • XML Namespace

These properties allow you to have control over the XML that will be generated.


XmlType Property

This property may have one of the following values:

  • Element: This is the default value. The element (member) will be serialized as an XML Element.
  • Attribute: The member will appear as an XML attribute but in the last level of the parent element.
  • CData: The member will be serialized as an element with a CDATA. It is usually used with values that contain XML.
  • Value: The member will be the Value of the parent Element.

XML Namespace property

Compound Elements

They are those elements defining a new element group, a new collection, or a group of simple elements.

Different bullets, in the editor, identify the compound elements:

MemberBullet Identifies a member in an SDT

CollectionBullet Identifies a collection

StructureBullet Identifies a structure, a group of simple elements

Compound elements have the same properties as simple elements, but the Data Type property is not enabled.

In the following example you can see a Structured Data Type named Customers with some simple and compound elements:


Now look at the corresponding Properties windows:

StructureProp CollectionProp SubstructureProp

When a substructure defines a collection, besides the data type created with the SDT name, there will be another data type created with Name.SubstructureName, and they will be selectable as data types in any variable definition. This means that the two data types will be created. Following the example, while defining variables in a procedure, you may see:


Stop and take a look again at the image of the Collection properties window. Can you see the Collection Serialization property?


The purpose of this property is to help solve the problem of how to serialize a collection. Its possible values are:

  • Wrapped: Default value. Includes the collection start/end tag.
  • Sequence: Will serialize as a plain sequence of collection elements.

Different Actions over Each Kind of Element

As with any other editor, the SDT editor allows you to define actions over each kind of element by right-clicking on:

  • Structured Data Type
  • Collection
  • Member

Drag and drop: You can select a Transaction from the Folder View and drop it into the SDT structure. The Transaction structure will be added to the SDT structure.

Structured Data Type

By right-clicking on a Structured Data Type you will see the following secondary menu:


References History

Note: When you need to insert a new member in the structure, you may use the corresponding option in this secondary menu shown above, or you may also drag the attribute to the structure. Look at the following image:


Another method for inserting members in the SDT structure is to use the Insert Menu from the GeneXus main toolbar.
The available menu options are :

  • Insert Attribute: inserts a member with the same name and with type based on the selected attribute
  • Insert Domain: inserts a member with the same name and with type based on the selected domain
  • Insert Object (only Transactions can be selected): inserts one member for each attribute in the Transaction structure, with the same name and type based on it. Note: If the description of an attribute of the Transaction changes, it also changes in the SDT structure (as since GeneXus 15 upgrade 3).

If the focus is on the SDT structure root, the new members added with the Insert menu will be placed on the end of the structure, if the focus is on one existing member, the new member will be added immediately after the selected one.


By right-clicking on a Collection you will see the following secondary menu:


  • Delete: Deletes the Collection.
  • Move Items Up: Moves the Collection up in the SDT structure.
  • Move Items Down: Moves the Collection down in the SDT structure.
  • Indent: Adds the selected collection under a new collection.
  • Unindent: Takes the selected collection away from its container collection.
  • Insert Member: This allows you to insert a new member to the collection.
  • Insert Sibling Substructure: This allows you to define a substructure under the SDT structure (under Customers, in the example above).
  • Properties: Displays the Properties window.


By right-clicking on a Substructure you will see a secondary menu quite similar to the Collection menu:



By right-clicking on a Member you will see a secondary menu quite similar to the Collection menu:


Examples of SDT Serialization to XML

1) Suppose that you have the following SDT:


You want to generate the following XML:

Richard Smith

So, you will need to set the following values to the corresponding properties:

  • XmlType property in Id member: attribute
  • XmlType property in Name member: value

2) Suppose that you have now defined an SDT like the one below:


The collection may be serialized as follows:


In this case, the Collection Serialization property must be specified as Wrapped

Or as:


In this case, the Collection Serialization property must be specified as Sequence

Defining a Collection Based on Any Data Type

By working with the SDT Editor, you may define collections as shown in the following image:


However, you will not be able to define a collection based on any Data Type (Numeric, Character, another SDT data type, BC, etc). In order to solve this situation, you must work with Collection Domains, or you may even define a Collection Variable based on the corresponding Data Type, as shown below.

Collection Variable

See Also

Recursive SDTs Implementing SDT Collections


Start Video Compound data types
Start Video Loading Compound Data Types (SDT) using Data Providers

Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant