Skip to content

Commit b50f35c

Browse files
committed
Merge pull request #14 from donmendelson/rc4-xsd-offset
Offsets within composite types #11 and #12
2 parents 13afeea + f0c92a7 commit b50f35c

File tree

2 files changed

+68
-22
lines changed

2 files changed

+68
-22
lines changed

v1-0-RC4/doc/04MessageSchema.md

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ their encodings.
5858
| id | Unique identifier of a schema | unsignedInt | | Should be unique between counterparties |
5959
| version | Version of this schema | nonnegativeInteger | | Initial version is zero and is incremented for each version |
6060
| semanticVersion | Version of FIX semantics | string | optional | FIX versions, such as “FIX.5.0\_SP2” |
61-
| byteOrder | Byte order of encoding | token | default = littleEndian | littleEndian bigEndian |
61+
| byteOrder | Byte order of encoding | token | default = littleEndian | littleEndian bigEndian |
6262
| description | Documentation of the schema | string | optional | |
6363
| headerType | Name of the encoding type of the message header, which is the same for all messages in a schema. | string | default= messageHeader | An encoding with this name must be contained by \<types\>. |
6464

@@ -145,8 +145,7 @@ The element value represents a constant if attribute
145145
| maxValue | Highest acceptable value | string | | |
146146
| length | Number of elements of the primitive data type | nonnegativeInteger | default = 1 | Value “0” represents variable length. |
147147
| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | See section 4.4.4.3 below |
148-
| primitiveType | The primitive data type that backs the encoding | token | required | char int8 int16 int32 int64 uint8 uint16 uint32 uint64 float double
149-
|
148+
| primitiveType | The primitive data type that backs the encoding | token | required | char int8 int16 int32 int64 uint8 uint16 uint32 uint64 float double |
150149
| semanticType | Represents a FIX data type | token | optional | Same as field semanticType – see below. |
151150
| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. |
152151
| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. |
@@ -208,7 +207,7 @@ constant exponent, which is not sent on the wire.
208207

209208
If a message designer wishes to control byte boundary alignment or map
210209
to an existing data structure, element offset may optionally be
211-
specified on simple types within a composite type. Offset is the number
210+
specified on a simple type, enum or bitset within a composite type. Offset is the number
212211
of octets from the start of the composite; it is a zero-based index.
213212

214213
If specified, offset must be greater than or equal to the sum of the
@@ -221,6 +220,37 @@ For a composite type, nullness is indicated by the value of its first
221220
element. For example, if a price field is optional, a null value in its
222221
mantissa element indicates that the price is null.
223222

223+
### Reference to reusable types
224+
225+
A composite type often has its elements defined in-line within the `<composite>` XML element as shown in the example above. Alternatively, a common type may be defined once on its own, and then referred to by name with the composite type using a `<ref>` element.
226+
227+
#### `<ref>` attributes
228+
229+
| \<ref\> attribute | Description | XML type | Usage | Valid values |
230+
|--------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------|
231+
| name | Usage of the type in this composite | symbolicName\_t | required | |
232+
| type | Name of referenced encoding | symbolicName\_t | required | Must match a defined type, enum or set name attribute. |
233+
| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. |
234+
| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. |
235+
236+
#### Type reference example
237+
238+
In this example, a futuresPrice is encoded as 64 bit integer mantissa, 8 bit exponent, and a reused enum type. Note that a
239+
reference may carry an offset within the composite encoding that contains it.
240+
241+
```xml
242+
<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean">
243+
<validValue name="false">0</validValue>
244+
<validValue name="true">1</validValue>
245+
</enum>
246+
247+
<composite name="futuresPrice">
248+
<type name="mantissa" primitiveType="int64" />
249+
<type name="exponent" primitiveType="int8" />
250+
<ref name="isSettlement" type="boolEnum" offset="9" />
251+
</composite>
252+
```
253+
224254
### Enumeration encodings
225255

226256
An enumeration explicitly lists the valid values of a data domain. Any
@@ -238,10 +268,10 @@ The encoding of an enumeration may be char or any unsigned integer type.
238268
|--------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|-----------------------------------------------------------------------------------|
239269
| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. |
240270
| description | Documentation of the type | string | optional | |
241-
| encodingType | Name of a simple encoding type | symbolicName\_t | required | Must match the name attribute of a scalar \<type\> element *or* a primitive type: char uint8 uint16 uint32 uint64
242-
| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. |
271+
| encodingType | Name of a simple encoding type | symbolicName\_t | required | Must match the name attribute of a scalar \<type\> element *or* a primitive type: char uint8 uint16 uint32 uint64 |
272+
| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. |
243273
| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. |
244-
274+
| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional |
245275

246276
#### `<validValue>` element attributes
247277

@@ -300,6 +330,7 @@ The encoding of a bitset should be an unsigned integer type.
300330
| encodingType | Name of a simple encoding type | string | required | Must match the name attribute of a scalar \<type\> element *or* a primitive type: uint8 uint16 uint32 uint64 |
301331
| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. |
302332
| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema.
333+
| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional |
303334

304335
#### `<choice>` element attributes
305336

@@ -558,4 +589,4 @@ Reserved element names
558589
| unit | timestamp, TZ time |
559590
| version | messageHeader |
560591
| week | MonthYear |
561-
| year | MonthYear |
592+
| year | MonthYear |

v1-0-RC4/resources/SimpleBinary1-0.xsd

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,6 @@
171171
<xs:attribute name="maxValue" type="xs:string" use="optional" />
172172
<xs:attribute name="length" type="xs:nonNegativeInteger"
173173
default="1" />
174-
<xs:attribute name="offset" type="xs:unsignedInt" use="optional">
175-
<xs:annotation>
176-
<xs:documentation>Offset from start of a composite type as a
177-
zero-based index.
178-
</xs:documentation>
179-
</xs:annotation>
180-
</xs:attribute>
181174
<xs:attribute name="primitiveType" use="required">
182175
<xs:simpleType>
183176
<xs:restriction base="xs:token">
@@ -197,6 +190,7 @@
197190
</xs:attribute>
198191
<xs:attribute name="characterEncoding" type="xs:string"
199192
use="optional" />
193+
<xs:attributeGroup ref="sbe:alignmentAttributes" />
200194
<xs:attributeGroup ref="sbe:presenceAttributes" />
201195
<xs:attributeGroup ref="sbe:semanticAttributes" />
202196
<xs:attributeGroup ref="sbe:versionAttributes" />
@@ -215,8 +209,10 @@
215209
<xs:element name="enum" type="sbe:enumType" />
216210
<xs:element name="set" type="sbe:setType" />
217211
<xs:element name="composite" type="sbe:compositeDataType" />
212+
<xs:element name="ref" type="sbe:refType" />
218213
</xs:choice>
219214
<xs:attribute name="name" type="sbe:symbolicName_t" use="required" />
215+
<xs:attributeGroup ref="sbe:alignmentAttributes" />
220216
<xs:attributeGroup ref="sbe:semanticAttributes" />
221217
<xs:attributeGroup ref="sbe:versionAttributes" />
222218
</xs:complexType>
@@ -234,6 +230,7 @@
234230
<xs:attribute name="name" type="sbe:symbolicName_t" use="required" />
235231
<xs:attribute name="encodingType" type="sbe:symbolicName_t"
236232
use="required" />
233+
<xs:attributeGroup ref="sbe:alignmentAttributes" />
237234
<xs:attributeGroup ref="sbe:semanticAttributes" />
238235
<xs:attributeGroup ref="sbe:versionAttributes" />
239236
</xs:complexType>
@@ -254,6 +251,19 @@
254251
</xs:simpleContent>
255252
</xs:complexType>
256253

254+
<xs:complexType name="refType" mixed="true">
255+
<xs:annotation>
256+
<xs:documentation>
257+
A reference to any existing encoding type (simple type, enum or set)
258+
to reuse as a member of a composite type
259+
</xs:documentation>
260+
</xs:annotation>
261+
<xs:attribute name="name" type="sbe:symbolicName_t" use="required" />
262+
<xs:attribute name="type" type="sbe:symbolicName_t" use="required" />
263+
<xs:attributeGroup ref="sbe:alignmentAttributes" />
264+
<xs:attributeGroup ref="sbe:versionAttributes" />
265+
</xs:complexType>
266+
257267
<xs:complexType name="setType" mixed="true">
258268
<xs:annotation>
259269
<xs:documentation>
@@ -266,6 +276,7 @@
266276
<xs:attribute name="name" type="sbe:symbolicName_t" use="required" />
267277
<xs:attribute name="encodingType" type="sbe:symbolicName_t"
268278
use="required" />
279+
<xs:attributeGroup ref="sbe:alignmentAttributes" />
269280
<xs:attributeGroup ref="sbe:semanticAttributes" />
270281
<xs:attributeGroup ref="sbe:versionAttributes" />
271282
</xs:complexType>
@@ -302,13 +313,6 @@
302313
</xs:documentation>
303314
</xs:annotation>
304315
</xs:attribute>
305-
<xs:attribute name="offset" type="xs:unsignedInt" use="optional">
306-
<xs:annotation>
307-
<xs:documentation>Offset from start of a block as a zero-based
308-
index.
309-
</xs:documentation>
310-
</xs:annotation>
311-
</xs:attribute>
312316
<!-- start of time period - default is UNIX epoch -->
313317
<xs:attribute name="epoch" type="xs:string" default="unix" />
314318
<xs:attribute name="timeUnit" type="xs:string" default="nanosecond">
@@ -317,6 +321,7 @@
317321
</xs:documentation>
318322
</xs:annotation>
319323
</xs:attribute>
324+
<xs:attributeGroup ref="sbe:alignmentAttributes" />
320325
<xs:attributeGroup ref="sbe:presenceAttributes" />
321326
<xs:attributeGroup ref="sbe:semanticAttributes" />
322327
<xs:attributeGroup ref="sbe:versionAttributes" />
@@ -359,6 +364,16 @@
359364
</xs:attribute>
360365
</xs:attributeGroup>
361366

367+
<xs:attributeGroup name="alignmentAttributes">
368+
<xs:attribute name="offset" type="xs:unsignedInt" use="optional">
369+
<xs:annotation>
370+
<xs:documentation>Offset from start of a composite type or block
371+
as a zero-based index.
372+
</xs:documentation>
373+
</xs:annotation>
374+
</xs:attribute>
375+
</xs:attributeGroup>
376+
362377
<xs:attributeGroup name="presenceAttributes">
363378
<xs:attribute name="presence" default="required">
364379
<xs:simpleType>

0 commit comments

Comments
 (0)