MRM TDS format: Relationship to the logical model
TDS separation types and logical model properties have some restrictions, such as group composition and group content validation.
The rules that govern these options are explained in Message Sets: Restrictions for nesting complex types.
These rules exist to ensure the integrity of the message. A combination of separation type and group composition or group content validation must not lead to a message that is unclear to a TDS parser.
Default values
In TDS, Default values are only observed by fixed-length elements:
Separation Type | Use of Default values |
---|---|
Tagged Delimited
Tagged Fixed Length Tagged Encoded Length All Elements Delimited Data Pattern |
Default values are never observed. |
Fixed Length
Fixed Length AL3 |
Default values are observed on output by all elements. An absent element that has no Default value defined, causes an error on writing. |
Variable Length Elements Delimited | Default values are only observed by fixed-length elements on output. Absent fixed-length values must have a Default value available to them. An absent element that has no Default value defined, causes an error on writing. |
Simple types - lists and unions
Lists and unions are XML-specific concepts. An element or attribute of a simple type that is a list or a union causes a task list warning if a TDS physical format is present in the message set. The user can choose whether to make this an error, warning, or information by editing the Validation preferences. If a dictionary is generated from the message set, and an attempt is made to parse a TDS message defined to contain such elements or attributes, a runtime error occurs.
Min Occurs and Max Occurs
The logical properties Min Occurs and Max Occurs specify the permitted number of occurrences of an element or group in a message. They are used when parsing and writing messages, and when validating the content of a message.
When parsing and writing, the exact interpretation of these properties depends on the Data Element Separation property of the parent complex type or group as shown in the following table.
However, this behavior is overridden if the TDS Repeat Reference property is set, which indicates that the number of occurrences is given instead by an integer element that occurs earlier in the message. See Repeat reference for more information.
When validating, Min Occurs and Max Occurs are both used to check that the content of the message tree matches the model.
Separation type | Interpretation of Min Occurs and Max Occurs |
---|---|
Tagged Delimited
Tagged Fixed Length Tagged Encoded Length |
Min Occurs and Max Occurs are effectively ignored
when parsing and writing. When parsing, the number of occurrences
is identified by the tags in the message. When writing, the writer outputs
all occurrences in the message tree.
|
All Elements Delimited | Max Occurs is
used only when parsing and writing, with the element's Repeating Element Delimiter property,
and the parent type's Suppress
Absent Element Delimiters property. A varying number of occurrences (Min Occurs <> Max Occurs) is allowed if Suppress Absent Element Delimiters is set to End of Type.
If Suppress Absent Element Delimiters is Never, all occurrences are expected when parsing, and produced when writing, although parsing accepts elements being absent. Optional occurrence (Min Occurs = 0) is ignored and a delimiter is still expected when parsing, and produced when writing. Always absent (Max Occurs = 0) is allowed. No delimiter is expected when parsing, nor output when writing. An unbounded number of occurrences (Max Occurs = -1) is only allowed if the Repeating Element Delimiter is different from the Delimiter. The repeats must be terminated by the delimiter, or a containing group's Group Terminator or Delimiter, or by the end of the message bit stream. On writing, the writer outputs all occurrences in the message tree. |
Fixed Length
Fixed Length AL3 |
Max Occurs is
used only when parsing and writing. In general, Max Occurs occurrences are expected
when parsing, and Max Occurs occurrences
are produced when writing; default values are used for missing elements,
and any excess elements are discarded. A varying number of occurrences (Min Occurs <> Max Occurs) is ignored, Max Occurs is assumed. Optional occurrence (Min Occurs = 0) is ignored, Max Occurs is assumed. Always absent (Max Occurs = 0) is allowed. Fixed Length only. An unbounded number of occurrences (Max Occurs = -1) is allowed if the element or group is the last child in its parent group, and the group is terminated by a Group Terminator or a containing group's Group Terminator or Delimiter or by the end of the message bit stream. On writing, the writer outputs all occurrences in the message tree, if this number is less than Min Occurs, additional default values are written. |
Variable Length Elements Delimited | For fixed length simple elements, the rules
for Fixed Length separation above
are followed with two differences.
For variable length simple elements, all complex elements and groups, the rules for All Elements Delimited above are followed. |
Data Pattern | Min Occurs and Max Occurs are effectively ignored
when parsing and writing. When parsing, the pattern is matched as
many times as possible. When writing, the writer outputs all occurrences
in the message tree. Note that on parsing, if the data pattern permits
a zero length match, and a zero length match occurs, an element is
added to the message tree, and the matching terminates to prevent
an infinite loop. A varying number of occurrences (Min Occurs <> Max Occurs) is allowed. Optional occurrence (Min Occurs = 0) is allowed. Always absent (Max Occurs = 0) is allowed. An unbounded number of occurrences (Max Occurs = -1) is allowed. |
Repeat reference
The TDS property Repeat reference specifies a field that holds the number of repeats of an object (Element or Group) within a message. The field that holds the number of repeats must be within the message before the object that it refers to.
From a parsing perspective, the Repeat reference property replaces the role of the minOccurs and maxOccurs properties.
If a value for the Repeat reference property is specified for an object, values that are specified for minOccurs and maxOccurs are ignored when parsing and writing. However, values that are specified for minOccurs and maxOccurs are used by logical validation.
When parsing and writing, the exact interpretation of the Repeat reference property depends on the Data Element Separation property of the parent complex type or group as shown in the following table.
Separation type | Interpretation of Repeat reference |
---|---|
Tagged Delimited
Tagged Fixed Length Tagged Encoded Length |
Repeat reference is effectively ignored when parsing and writing. When parsing, the number of occurrences is identified by the tags in the message. When writing, the writer outputs all occurrences in the message tree. |
All Elements Delimited | Repeat reference is
used when parsing and writing, with the element's Repeating Element Delimiter property,
and the parent type's Suppress
Absent Element Delimiters property. A Repeat reference is allowed only if the parent complex type or group has Suppress Absent Element Delimiters set to Never. All Repeat reference occurrences are expected when parsing, and produced when writing. However, parsing accepts elements being absent. Repeat reference = 0 is allowed. No delimiter is expected when parsing, nor produced when writing. |
Fixed Length
Fixed Length AL3 |
Repeat reference is
used when parsing and writing. Repeat
reference occurrences are expected when parsing, and are
produced when writing, with default values used for missing elements.
Repeat reference = 0 is allowed. |
Variable Length Elements Delimited | For fixed length simple elements, the rules
for Fixed Length separation above
are followed. For variable length simple elements, all complex elements and groups, the rules for All Elements Delimited that are listed above are followed. |
Data Pattern | Repeat reference is effectively ignored when parsing and writing. When parsing, the pattern is matched as many times as possible. When writing, the writer outputs all occurrences in the message tree. Note that, on parsing, if the data pattern permits a zero length match, and a zero length match occurs, an element is added to the message tree, and the matching terminates to prevent an infinite loop. |