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/14 16:23:46 UTC

Best Practice in describing integers?

Hello DFDL community,

Below are two ways a DFDL schema may describe integers. One way uses lots of DFDL properties. The other way using XML Schema facets. Which way do you think is better? I've listed pros and cons of each way. Are there other pros and cons?  /Roger

[cid:image003.png@01D5529B.1D435C60]

[cid:image004.png@01D5529B.1D435C60]

[cid:image005.png@01D5529B.1D435C60]






Re: Best Practice in describing integers?

Posted by Steve Lawrence <sl...@apache.org>.
I think you hit on the biggest drawback of using a pattern facet, is
that it becomes very difficult to use the value. By using the DFDL
properties, Daffodil will canonicalize the number so users don't have to
worry about what the actual form was in the data. In your simple
example, it's not too bad, but what if the data contained:

  (123,456e3)

This is a negative number with grouping separators and an exponent. If
this was put in the infoset, a user would need to strip parenthesis and
commas, realize it's negative, and expand the exponent to figure out
what the number is. But if you use DFDL properties, Daffodil does all
the for you, and the infoset contains :

  123456000

Which is much easier to use and reason about.

Related, since the number is an actual integer in the infoset, you can
now use things like min/maxInclusive to validate the int value. You
can't do this if you treat is as a string. The checkconstrains/pattern
facet doesn't allow this kind of validation.


On 8/14/19 12:23 PM, Costello, Roger L. wrote:
> Hello DFDL community,
> 
> Below are two ways a DFDL schema may describe integers. One way uses lots of 
> DFDL properties. The other way using XML Schema facets. Which way do you think 
> is better? I’ve listed pros and cons of each way. Are there other pros and cons? 
> /Roger
>