Data Format Description Language (DFDL) v1.0 Specification
OGF Proposed Recommendation GFD-P-R.174, January 31, 2011


12.1 Aligned Data

Alignment properties control the leading alignment and trailing alignment regions.

The following properties are used to define alignment rules.

Property Name

Description

alignment

Non-negative Integer or 'implicit'

A non-negative number that gives the alignment required for the beginning of the item. If alignment is required then the size of the AlignmentFill grammar region will be non-zero if the item must be aligned to a boundary.

The alignment of a child component must be less than or equal the alignment of its parent element, sequence or choice.

‘implicit' specifies that the natural alignment for the representation type is used. See the table of implicit alignments Table 14 Implicit Alignment in bits for simple elements. The 'implicit' alignment of complex elements and groups is the alignment of its child with the greatest alignment. If alignment is 'implicit' then alignmentUnits is ignored.

Annotation: dfdl:element, dfdl:simpleType, dfdl:sequence, dfdl:choice, dfdl:group

alignmentUnits

Enum

Valid values are ‘bits’ or ‘bytes’

Scales the alignment so alignment can be specified in either units of bits or units of bytes.

Only used when dfdl:alignment not 'implicit'

Annotation: dfdl:element, dfdl:simpleType, dfdl:sequence, dfdl:choice, dfdl:group

fillByte

DFDL String Literal

A single byte specified as a DFDL byte value entity or a single character. If a character is specified, it must be a single-byte character in the applicable encoding.

Used on unparsing to fill empty space such as between two aligned elements.

Used to fill these regions specified in the grammar: RightPadOrFill, FinalUnusedRegion, LeadingSkip, AlignmentFill, and TrailingSkip.

Annotation: dfdl:element, dfdl:simpleType, dfdl:sequence, dfdl:choice, dfdl:group

leadingSkip

Non-negative Integer

A non-negative number of bytes or bits, depending on dfdl:alignmentUnits, to skip before alignment is applied. Gives the size of the grammar region having the same name.

Annotation: dfdl:element, dfdl:simpleType, dfdl:sequence, dfdl:choice, dfdl:group

trailingSkip

Non-negative Integer

A non-negative number of bytes or bits, depending on dfdl:alignmentUnits, to skip after the element, but before considering the alignment of the next element. Gives the size of the grammar region having the same name.

If dfdl:trailingSkip is specified when dfdl:lengthKind is 'delimited' or 'endOfParent' then a dfdl:terminator must be specified.

Annotation: dfdl:element, dfdl:simpleType, dfdl:sequence, dfdl:choice, dfdl:group

There are two properties which control the data alignment by controlling the length of the Alignment Fill Region

An element's representation is aligned to N units if P is the first position in the representation and P mod N = 1.  When parsing, the position of the first unit of the data stream is 1. 

For example, if alignment=4, and alignmentUnits='bytes', then the element's representation must begin at 1 or 1 plus a multiple of a 4 bytes. I.e., 1, 5, 9, 13, 17 and so on.

The length of the alignment fill region is measured in bits. If alignmentUnits is ‘bytes’ then we multiply the alignment value by 8 to get the bit alignment, B. If the current position (first position after the end of the previous element) value is bit position N, then the length of the alignment fill region is the smallest non-negative integer L such that (L + N) mod B = 1.  The position of the first bit of the aligned element is P = L + N.

To avoid ambiguity when parsing, optional elements and variable-occurrence arrays where the minimum number of occurrences is zero cannot have alignment properties different from the items that follow them. It is a schema definition error otherwise. This avoids the possibility that the following item is incorrectly parsed as if it were a valid optional element or variable-occurrence array element.

The leading skip and trailing skip regions length are controlled by two properties of corresponding names and the dfdl:alignmentUnits property.

12.1.1 Implicit Alignment

When dfdl:alignment is 'implicit' the following alignment values are applied for each logical type.
 

Representation

 

text

binary

String

8

Not applicable

 

Float

8

32

 

Double

8

64

 

Decimal, Integer, nonNegativeInteger

8

packed/bcd :8

binary: 8

Long, UnsignedLong

8

packed/bcd : 8

binary: 64

Int, UnsignedInt

8

packed/bcd : 8

binary: 32

Short, UnsignedShort

8

packed/bcd : 8

binary: 16

Byte, UnsignedByte

8

packed/bcd : 8

binary: 8

DateTime

8

packed/bcd: 8

binarySeconds: 32, binaryMilliseconds:64

Date

8

packed/bcd : 8

binarySeconds: 32, binaryMilliseconds:64

Time

8

packed/bcd : 8

binarySeconds: 32, binaryMilliseconds:64

Boolean

8

32

 

HexBinary

Not applicable

8

 
Table 14 Implicit Alignment in bits

 

Note: Specifying the implicit alignment in bits does not imply that dfdl:lengthUnits 'bits' can be specified for all simple types.

Copyright (C) Open Grid Forum (2005-2010). All Rights Reserved.

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the OGF or other organizations, except as needed for the purpose of developing Grid Recommendations in which case the procedures for copyrights defined in the OGF Document process must be followed, or as required to translate it into languages other than English.