I gave it a go Steve and opened a PR: 
https://github.com/apache/incubator-daffodil/pull/387. Assuming it's merged, 
can we have patch release for this? We are preparing to release the EDI 
cartridge for Smooks 2 (https://github.com/smooks/smooks-edi-cartridge) but 
there are many places in our generated EDIFACT schemas with totalDigits > 9.

Claude

On 2020/06/09 11:41:20, Steve Lawrence <slawre...@apache.org> wrote: 
> Looks like total digits is just plain broken for anything greater than
> or equal to 10, which is pretty bad. Looking at the code I *think* the
> totalDigits check will always succeed if the value being validated is
> negative, regardless of the number of digits.
> 
> I've created DAFFODIL-2349 [1] to track this issue.
> 
> If you (or anyone else) is interested in getting involved in Daffodil
> development, this would be a good one to get your feet wet. The fix
> should be pretty self-contained to one file/function.
> 
> Unfortunately, I'm not sure if there's a good workaround using just
> restrictions.
> 
> Best I can come up with is have an inputValueCalc that strips out a
> negative sign and decimal place, and then restrict that to a length of
> 10, e.g.
> 
>   <xs:element name="unscaled" dfdl:inputValueCalc="{
>     fn:concat(
>       fn:substring-before(xs:string(fn:abs(../value)), '.'),
>       fn:substring-after(xs:string(../value), '.')
>     )
>   }">
>   <xs:simpleType>
>     <xs:restriction base="xs:string">
>       <x:length value="10"/>
>     </xs:restriction>
>   </xs:simpleType>
> </xs:element>
> 
> That's pretty terrible though. Maybe someone else can come up with a
> better workaround?
> 
> [1] https://issues.apache.org/jira/browse/DAFFODIL-2349
> 
> 
> On 6/9/20 2:29 AM, Claude Mamo wrote:
> > Hello Daffodil team,
> > 
> > Not sure if what I'm getting is expected behaviour. I have a facet defined 
> > as follows:
> > 
> > ```
> >     <xsd:simpleType dfdl:textNumberPattern="#.#" name="numeric1-10">
> >         <xsd:restriction base="xsd:decimal">
> >             <xsd:totalDigits value="10"/>
> >         </xsd:restriction>
> >     </xsd:simpleType>
> > ```
> > 
> > When attempting to parse a file with full validation turned on, Daffodil 
> > 2.6 throws an exception saying:
> > 
> > ```
> > org.apache.daffodil.exceptions.Abort: 
> > Invariant broken. Exception thrown with mark not returned: 
> > java.lang.ArithmeticException: Overflow
> > StackTrace:
> > java.lang.ArithmeticException: Overflow
> >         at java.math.BigDecimal.intValueExact(BigDecimal.java:3180)
> >         at 
> > org.apache.daffodil.processors.SimpleTypeRuntimeData.checkTotalDigits(RuntimeData.scala:526)
> >         at 
> > org.apache.daffodil.processors.SimpleTypeRuntimeData.$anonfun$executeFacetCheck$8(RuntimeData.scala:431)
> >         at 
> > org.apache.daffodil.processors.SimpleTypeRuntimeData.$anonfun$executeFacetCheck$8$adapted(RuntimeData.scala:427)
> > ```
> > 
> > Should I create a bug report? Any suitable alternatives to "totalDigits"?
> > 
> > Claude
> > 
> >         
> > 
> 
> 

Reply via email to