For the broader DFDL workgroup (Martin,
Simon, and any other onlookers), this proposal was circulated among the
IBM DFDLers and we liked it, so we wanted others to take a look.
------------------------------------------------------------------------
Prefix lengths are common, but unfortunately
there are many prefix length formats.
For flexibility we want to be able to
use a hidden field and calc properties, but this is clumsy enough to be
very unattractive except for extreme cases. However, without it we have
the keyword proliferation issue.
Here's a way to get the best of both
worlds.
<element name="myString"
type="string"
dfdl:lengthKind="prefixed" dfdl:lengthPrefixType="packed4"/>
here's the trick. Named types for length
prefixes are just a real schema type definition of an integer type with
dfdl annotations. .
<simpleType name="packed4">
<restriction
base="integer" dfdl:representation="decimal" dfdl:decimalType="packed"
dfdl:numberFormat="9999" dfdl:decimalSigned="false"
dfdl:prefixIncludesPrefixLength="false"/>
</simpleType>
The behavior is simple. Imagine that
a hidden length prefix element is defined immediately before your element,
and it's type is the one given here.
You don't have to model that hidden
element. DFDL knows how to do that for you. Just tell us it's type, including
DFDL properties for the representation
of that type.
We could build in a few of these to
some predefined profiles. E.g., dfdl:prefix2, and dfdl:prefix4 might be
the typical 2 and 4 byte length prefix definitions you see
in PL1 for example.
I suggest the above because of the slippery
slope where we have to gradually bifurcate all the integer properties to
have lengthPrefix flavors of them
e.g.,
lengthPrefixRepresentation = text or
binary or decimal
lengthPrefixLengthUnits = bits, bytes,
or characters
lengthPrefixLength = an integer
lengthPrefixLengthIncludesPrefix (boolean)
lengthPrefixTextNumberJustification
lengthPrefixTextNumberFormat
Anywhere you stop here there will be
many cases that aren't covered.