The issue here is that your dfdl:textNumberPattern probably has commas
in it. If you're using DFDLGeneralFormat, the pattern looks something
like this:

  dfdl:textNumberPattern="#,##0.###;-#,##0.###"

So when Daffodil tries to unparse the text number "99999", it first
makes it match this pattern, so it will add commas every three digits
and a decimal if necessary. So "99999" will be unparsed as "99,999",
which is more than 5 characters, and so Daffodil errors.

You don't want any commas in your unparsed data, so you should probably
set the pattern property to something like this:

  dfdl:textNumberPattern="####0;-###0"

So either a 5 digit number, or a negative 4 digit number, with no commas
or decimals.

- Steve

On 6/19/19 8:12 AM, Costello, Roger L. wrote:
> Hello DFDL community,
> 
> My input consists of a string containing one to five characters. Each 
> character must be a digit character. Here is a sample input:
> 
>       99999
> 
> My DFDL schema uses the xs:unsignedInt datatype to constrain the string to 
> digits. It uses dfdl:length=5 to constrain the length of the string. 
> 
> I am trying to be very precise in my wording. Is the above wording correct?
> 
> Here is my DFDL schema:
> 
> <xs:element name="input">
>     <xs:complexType>
>         <xs:sequence>
>             <xs:element name="value" 
>               type="xs:unsignedInt" 
>               dfdl:lengthKind="explicit" 
>               dfdl:length="5" 
>               dfdl:lengthUnits="characters" />
>         </xs:sequence>
>     </xs:complexType>
> </xs:element>
> 
> Parsing the input 99999 produces this XML:
> 
> <input>
>   <value>99999</value>
> </input>
> 
> Unparsing produces this error message:
> 
> [error] Unparse Error: Data too long by 8 bits. Unable to truncate.
> 
> Here is the output of unparsing:
> 
> 99,999
> 
> Why does unparsing produce that error message? Is it a bug in Daffodil?
> 
> /Roger
> 

Reply via email to