Ah, it looks like we only require decimal and grouping separators for integers if the pattern contains a decimal or grouping separator. So it is probably correct behavior that they aren't needed for you.

Note that if the text pattern does contains decimal or grouping separators (or also the @ sign or E sign), then we do require both decimal and grouping separators. This is because when the pattern uses any of those, ICU looks for these separators (even for integers) and if they don't exist it gets them from the system locale. That can lead to system dependent behavior, and issues.

For example, say your pattern was this:

  "#,###"

If you only specify grouping separator as a comma, but not decimal separator, ICU will get the decimal separator from the locale, which in some locales is a comma. So now both the grouping separator and decimal separator are commas, which causes issues when parsing.

So if Daffodil determines you need one, you'll need both.


On 11/8/21 11:29 AM, Roger L Costello wrote:
I think you may also always need textStandardDecimalSeparator and
textStandardGroupingSeparator since different locales use different
separators. E.g. is 1,234 the integer 1234 or decimal 1.234.

I didn't have either of those properties in my DFDL schema and Daffodil did not 
throw an error. Bug in Daffodil?

NumStudents is an integer, not a decimal, so why would 
textStandardDecimalSeparator be needed?

Once the bugs are fixed in Daffodil, is this how NumStudents will be declared? 
(I am assuming the textStandardDecimalSeparator is not needed)

<xs:element name="NumStudents" type="xs:integer"
     dfdl:textNumberPattern="#"
     dfdl:textNumberRep="standard"
     dfdl:textStandardBase="10"
     dfdl:textStandardExponentRep="e"
     dfdl:textStandardZeroRep="zero"
     dfdl:textStandardGroupingSeparator=","
/>



-----Original Message-----
From: Steve Lawrence <slawre...@apache.org>
Sent: Monday, November 8, 2021 11:17 AM
To: users@daffodil.apache.org
Subject: [EXT] Re: Why do I need to specify the DFDL rounding properties for an 
integer data item?

I think you may also always need textStandardDecimalSeparator and
textStandardGroupingSeparator since different locales use different
separators. E.g. is 1,234 the integer 1234 or decimal 1.234.

I think the rounding related, infinity, and NaN properties might be the
only ones that integers don't really need.

On 11/8/21 10:20 AM, Roger L Costello wrote:
Thanks Mike. So, once the bugs are fixed in Daffodil, exactly what DFDL
properties will I use to specify NumStudents?  Will it be this:

<xs:element name="NumStudents" type="xs:integer"
       dfdl:textNumberPattern="#"
       dfdl:textNumberRep="standard"
       dfdl:textStandardBase="10"
       dfdl:textStandardExponentRep="E"
       dfdl:textStandardZeroRep="0"
/>

*From:* Mike Beckerle <mbecke...@apache.org>
*Sent:* Monday, November 8, 2021 10:14 AM
*To:* users@daffodil.apache.org
*Subject:* [EXT] Re: Why do I need to specify the DFDL rounding properties for
an integer data item?

Answer: The dependencies you see are due to bugs in Daffodil. Code sharing in
Daffodil often results in code paths being shared between many simple types like
floats and integers, hence, often the code path needing rounding specifiers is
taken even for ordinary non-rounding situations.

These are bugs. The DFDL spec provides a precedence of properties and that says
which properties are allowed to depend on or require the existence of others.
These unnecessary ones are all just due to code sharing in the Daffodil
implementation.

Because there is a minor workaround in Daffodil - just specify all of these in a
base format - we have not given much priority to fixing such bugs.

However, they're good beginner bugs for new people working on the code base, so
we should start marking them as such.

On Mon, Nov 8, 2021 at 8:36 AM Roger L Costello <coste...@mitre.org
<mailto:coste...@mitre.org>> wrote:

      I'd like to add to my question. Suppose NumStudents is an ordinary integer
      that every 1st grader understands: base 10, no exponents, 0 means no
      students. In that case, I don't understand why any of the properties shown
      below have to be specified. And yet they must, or an error will be
      generated. It seems to me that DFDL should make it possible to specify
      simple things simply, but this sure looks like an example of having to
      specify all sorts of complex properties to specify a very simple use case.
      Am I mistaken?  /Roger

      -----Original Message-----
      From: Roger L Costello <coste...@mitre.org <mailto:coste...@mitre.org>>
      Sent: Monday, November 8, 2021 9:11 AM
      To: users@daffodil.apache.org <mailto:users@daffodil.apache.org>
      Subject: Why do I need to specify the DFDL rounding properties for an
      integer data item?

      Hi Folks,

      My input is  a single integer representing the number of students in a
      classroom, e.g.,

               30

      The following  shows the declaration of the element NumStudents. Notice 
the
      plethora of DFDL properties. They are the minimum properties - if you omit
      any of them, you will get an error. I don't understand why the rounding
      properties are required. There's no rounding with integers, so why do I 
need
      to specify those properties? Even if rounding did apply to integers, then 
it
      is mighty odd to specify that rounding is not necessary
      (textNumberRoundingMode="roundUnnecessary") and then be required to 
specify
      the rounding increment (textNumberRoundingIncrement) ... doesn't that 
strike
      you as a bit odd?

      Also, I don't show it, but the fillByte property is required (if I delete
      it, an error is raised). Huh? Filling is a concept of binary data formats,
      not text data formats, so why do I need to specify it?  /Roger

      <xs:element name="NumStudents" type="xs:integer"
           dfdl:textNumberPattern="#"
           dfdl:textNumberRep="standard"
           dfdl:textStandardBase="10"
           dfdl:textStandardExponentRep="E"
           dfdl:textStandardZeroRep="0"
           dfdl:textNumberRounding="explicit"
           dfdl:textNumberRoundingMode="roundUnnecessary"
           dfdl:textNumberRoundingIncrement="1"
           dfdl:textNumberCheckPolicy="strict"
      />


Reply via email to