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 2019/08/27 15:54:12 UTC

Trying to understand lengthKind="prefixed"

Hello DFDL community,

I believe that lengthKind="prefixed" is used when the input data is prefixed by an integer which indicates the length of the data. For example, below the data is the string ABC and it is prefixed by the integer 3

3ABC

The 3 indicates that the length of the following data is 3 characters.

Do I understand correctly the purpose of lengthKind="prefixed"?

Assuming I understand its purpose correctly, why is this DFDL schema failing:

<xs:element name="D" type="xs:string"
                        dfdl:lengthKind="prefixed"
                        dfdl:prefixLengthType="D-type"
                        dfdl:prefixIncludesPrefixLength="no"/>

<xs:simpleType name="D-type"
                          dfdl:lengthKind="explicit"
                          dfdl:length="1">
    <xs:restriction base="xs:integer" />
</xs:simpleType>

Here is the error message that I get:

[error] Parse Error: Convert to Unlimited Size Integer (for xs:integer): Unable to parse 'B' (using up all characters).

What am I doing wrong, please?

/Roger



Re: Trying to understand lengthKind="prefixed"

Posted by Steve Lawrence <sl...@apache.org>.
Works for me, so I'd guess this has something to do with a property in
dfdl:format. I'm not sure what property could lead to that output though.

Can you provide the rest of the schema with the dfdl:format?

On 8/27/19 11:54 AM, Costello, Roger L. wrote:
> Hello DFDL community,
> 
> I believe that lengthKind="prefixed" is used when the input data is prefixed by 
> an integer which indicates the length of the data. For example, below the data 
> is the string ABC and it is prefixed by the integer 3
> 
> 3ABC
> 
> The 3 indicates that the length of the following data is 3 characters.
> 
> Do I understand correctly the purpose of lengthKind="prefixed"?
> 
> Assuming I understand its purpose correctly, why is this DFDL schema failing:
> 
> <xs:elementname="D"type="xs:string"
>                          dfdl:lengthKind="prefixed"
>                          dfdl:prefixLengthType="D-type"
>                          dfdl:prefixIncludesPrefixLength="no"/>
> 
> <xs:simpleTypename="D-type"
>                            dfdl:lengthKind="explicit"
>                            dfdl:length="1">
> <xs:restrictionbase="xs:integer"/>
> </xs:simpleType>
> 
> Here is the error message that I get:
> 
> *[error] Parse Error: Convert to Unlimited Size Integer (for xs:integer): Unable 
> to parse 'B' (using up all characters).*
> 
> What am I doing wrong, please?
> 
> /Roger
>