You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by "Costello, Roger L." <co...@mitre.org> on 2020/02/06 19:03:48 UTC

A text data value with an implicit length?

Hi Folks,

Consider this input:

8John Doe

The number indicates the length of the following string.

So there are two data items: the first data item is an integer and the second data item is a string.

I figured that for the first data item I could specify it this way

type = integer
lengthKind = implicit

Alas, I discovered: Type Integer cannot have lengthKind='implicit' when representation='text'

Table 18 in the specification confirms that.

I am seeking an example of a text data value with an implicit length, i.e.,

<xs:element name="example" type="???" dfdl:lengthKind="implicit" />

 Does such a thing exist? Is there ever a text data value whose length is implicit?

/Roger

Re: A text data value with an implicit length?

Posted by "Beckerle, Mike" <mb...@tresys.com>.
lengthKind 'implicit' is mostly for binary types. Like "xs:int" has 32 bit length with lengthKind 'implicit' and dfdl;binaryNumberRep="binary"

Consider this C struct:

struct {
   int x;
   int y;
}

Imagine that data written to a file from a 32-bit computer/compiler.

The natural way to model this in DFDL is

<sequence>
   <element name="x" type="xs:int" dfdl:lengthKind="implicit"/>
   <element name="y" type="xs:int" dfdl:lengthKind="implicit"/>
</sequence>

For your text case, if you really want to say the first element is a number, the second is a string, and that string WILL NOT start with digits, to achieve that you use lengthKind="pattern" and a regex that captures digits only.

________________________________
From: Costello, Roger L. <co...@mitre.org>
Sent: Thursday, February 6, 2020 2:03 PM
To: users@daffodil.apache.org <us...@daffodil.apache.org>
Subject: A text data value with an implicit length?

Hi Folks,

Consider this input:

8John Doe

The number indicates the length of the following string.

So there are two data items: the first data item is an integer and the second data item is a string.

I figured that for the first data item I could specify it this way

type = integer
lengthKind = implicit

Alas, I discovered: Type Integer cannot have lengthKind='implicit' when representation='text'

Table 18 in the specification confirms that.

I am seeking an example of a text data value with an implicit length, i.e.,

<xs:element name="example" type="???" dfdl:lengthKind="implicit" />

 Does such a thing exist? Is there ever a text data value whose length is implicit?

/Roger