I believe it boils down to two issues
1) checking for leading zero padding - can you do this by saying totalDigits is more than the number of non-zero digits? I think not, because totaldigits/fractiondigits just translate into range checks on decimal values created by filling up that precision with the digit "9". I.e., totalDigits=6 fractionDigits=2 means the same thing (for a decimal) as minInclusive=-9999.99 maxInclusive=9999.99.
Hmm. Do we allow total/fraction digits on non-decimal? I.e., on float or double? If we do there is an issue here.
2) optional decimal point. I.e., wants the pattern so can be strict about allowing 99.9 or 99 without decimal point, but not 99. as a variation. I.e., the allowed format syntax is clearly either a decimal number with specified fraction part, or it's an integer and has no decimal point.
In all these cases, I suggested this is modeled as a hidden or non-hidden string carrying the pattern facet, and a decimal value computed from the string using inputValueCalc.
I'd still like to know whether Roger had examples of logical xs:decimal values that he was unable to validate using the min/max inclusive/exclusive and total/fractional digits facets. That would be a justification for allowing pattern facets but only for validation (ie, same as how pattern facets are used for xs:string).
Regards
Steve Hanson
Architect, IBM Data Format Description Language (DFDL)
Co-Chair, OGF DFDL Working Group
IBM SWG, Hursley, UK
smh@uk.ibm.com
tel:+44-1962-815848
From: Mike Beckerle <mbeckerle.dfdl@gmail.com>
To: dfdl-wg@ogf.org,
Date: 24/05/2013 13:22
Subject: Re: [DFDL-WG] examples of decimal validation using pattern facet
Sent by: dfdl-wg-bounces@ogf.org
Forgot to distribute this to the WG.
I now recall one of the discussions of patterns on numbers was this.
XML has this characteristic that everything is both a string, and whatever type it's logical XML Schema type says it is.
So a pattern that requires leading zeros makes sense on an integer because in XML, everything is a string; hence, we can talk about a pattern facet for the string-behavior of what XML-schema tells us is an integer.
Not so in DFDL.
In DFDL, the integer is converted to a pure conceptual number. Facet constraints can have to do only with the value of this logical type. The facets aren't about the representation. They are about the value only.
Hence, talking about leading zeros on an integer simply doesn’t make sense. Leading zero is a representation concept.
Here's the simplest way to think about it. If I had binary integers, would this same pattern facet requiring leading zeros make sense? --- no it would not; and therefore it isn't allowed in DFDL for any integers, binary nor textual representations. Facets must be about the logical value, not the representation. Hence, patterns aren't allowed on numbers, because patterns are fundamentally about strings.
On Sat, May 18, 2013 at 2:42 PM, Mike Beckerle <mbeckerle.dfdl@gmail.com> wrote:
Roger costello of Mitre provides this example of using pattern facet.
Basically, it expresses several different possible formats, all of which are some combination of digits and a optional decimal point. In terms of cobol-style patterns it is one of these formats:
99
99.9
99.99
99.999
99.9999
I am not sure a textNumberPattern can handle the optionality of the decimal point. I know we can deal with the varying number of fraction digits, and the fixed number of integer digits, but conditional decimal point I am unsure about.
---------- Forwarded message ----------
From: Costello, Roger L. <costello@mitre.org>
Date: Fri, May 17, 2013 at 4:00 PM
Subject: RE: examples of decimal validation using pattern facet
To: Mike Beckerle <mbeckerle.dfdl@gmail.com>
Cc: "Cranford, Jonathan W." <jcranford@mitre.org>
Hello Mike,
Ø Can you send an example of the lat/lon validation
Ø you mentioned on yesterday's Daffodil call?
Here ya go:
<xsd:simpleType name="foo">
<xsd:restriction base="xsd:decimal"><xsd:minInclusive value="00"/>
<xsd:maxInclusive value="59.9999"/>
<xsd:pattern value="[0-9]{2}|[0-9]{2}\.[0-9]{1}|[0-9]{2}\.[0-9]{2}|[0-9]{2}\.[0-9]{3}|[0-9]{2}\.[0-9]{4}"/>
</xsd:restriction>
</xsd:simpleType>
/Roger
From: Mike Beckerle [mailto:mbeckerle.dfdl@gmail.com]
Sent: Thursday, May 16, 2013 8:15 AM
To: Costello, Roger L.
Subject: examples of decimal validation using pattern facet
Roger,
Can you send an example of the lat/lon validation you mentioned on yesterday's Daffodil call?
The other members of the workgroup are wondering what can't be done via totalDigits/fractionDigits, etc.
The rationale for why pattern facet is not supported on numbers in DFDL is that we already have a much more powerful mechanism for parsing and unparsing numbers called textNumberPattern. The pattern facet only allows pass/fail using a regex, and is considered redundant (and problematic) for numbers as a result.
...mike
--
Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com
--
Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com
--
Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com
--
dfdl-wg mailing list
dfdl-wg@ogf.org
https://www.ogf.org/mailman/listinfo/dfdl-wg
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU