Mike et al

See dev/users mail list for attached PDF.

In addition to unexpected <xs:unsignedInt> behavior, see unusual behavior
re:
fn:count
dfdl:outputValueCalc ... if (~) then ~ else

Attila

On Wed, Mar 16, 2022 at 12:26 PM Mike Beckerle <[email protected]> wrote:

> Created https://issues.apache.org/jira/browse/DAFFODIL-2676
>
> On Wed, Mar 16, 2022 at 12:21 PM Mike Beckerle <[email protected]>
> wrote:
>
> > Ok, I found the attachment. Sorry for the delay.
> >
> > The challenge here is you are thinking the
> > xs:unsignedInt(../Line1.02-Satellite) call will tolerate whitespace.
> Which
> > it seems they do not.
> >
> > I think this is a Daffodil bug, as the constructors like xs:unsignedInt
> > are supposed to work like they do in XPath, and the XPath functions spec
> > says when converting from strings, that whitespace normalization applies
> -
> > which trims all leading and trailing whitespace. It's less clear
> > about whether interior whitespace is collapsed, but definitely
> > leading/trailing seem to be trimmed.
> >
> > So I'll add a JIRA ticket about this.
> >
> > For how to work around, I suggest parsing the satellite field not as a
> > string, but as an unsignedInt from the start.
> >
> > So like:
> >
> > <xs:element name="satellite-num-range" type="xs:unsignedInt"
> > dfdl:lengthKind="explicit" dfdl:length="5"
> >   dfdl:textTrimKind="padChar" dfdl:textPadKind="padChar"
> > dfdl:textNumberPadCharacter="%SP;" dfdl:textNumberJustification="right"
> >   dfdl:textNumberPattern="####0"/>
> >
> > I didn't run this, but I think this will remove leading spaces, and add
> > leading spaces to your 5 character element.
> >
> > Another way to express this, since you need only leading padding is this:
> >
> > <xs:element name="satellite-num-range" type="xs:unsignedInt"
> > dfdl:lengthKind="explicit" dfdl:length="5"
> >   dfdl:textNumberPattern="* ####0"/>
> >
> > In that textNumberPattern the "* " means spaces are the pad character to
> > be used, and when there is no digit for the position of a "#" then the
> pad
> > character from the pattern (not the textNumberPadCharacter) is used.
> >
> > Both kinds of padding can be used together E.g., so you could have number
> > text right justified in a fixed-length field of width 6, using "*" to pad
> > to width 5 so that you can get " **123".
> >
> > <xs:element name="starPadNum" type="xs:unsignedInt"
> > dfdl:lengthKind="explicit" dfdl:length="6"
> >   dfdl:textTrimKind="padChar" dfdl:textPadKind="padChar"
> > dfdl:textNumberPadCharacter="%SP;" dfdl:textNumberJustification="right"
> >   dfdl:textNumberPattern="* ####0"/>
> >
> > I didn't run these, but this is, I believe, how it is supposed to work.
> >
> >
> >
> > On Tue, Mar 15, 2022 at 5:23 PM Attila Horvath <
> [email protected]>
> > wrote:
> >
> >> Attachment can be found on
> >> https://lists.apache.org/[email protected] list.
> >> Not sure why it didn't show up on dev - I sent msg to both lists.
> >>
> >> On Tue, Mar 15, 2022 at 3:41 PM Mike Beckerle <[email protected]>
> >> wrote:
> >>
> >> > No attached PDF.
> >> >
> >> > Removal of blanks from a number would normally be by way of DFDL
> >> "padding"
> >> > and "trimming" properties.
> >> >
> >> > You need dfdl:textNumberJustification property, also textTrimKind,
> >> > textPadKind, textNumberPadCharacter.
> >> >
> >> > You can also use textNumberPattern to indicate that a number may have
> >> > leading spaces or zeros, but this is mostly about output when those
> >> leading
> >> > zeros are required.
> >> >
> >> > Padding on left == Right Justified
> >> > Padding on right == Left Justified
> >> > Padding around both sides = Center Justified.
> >> >
> >> >
> >> >
> >> > On Tue, Mar 15, 2022 at 8:53 AM Attila Horvath <
> >> [email protected]
> >> > >
> >> > wrote:
> >> >
> >> > > Ping... any assistance appreciated - thx
> >> > >
> >> > > ---------- Forwarded message ---------
> >> > > From: Attila Horvath <[email protected]>
> >> > > Date: Mon, Mar 14, 2022 at 12:38 PM
> >> > > Subject: string to integer conversion w/ leading blanks fails
> >> > > To: <[email protected]>, <[email protected]>
> >> > >
> >> > >
> >> > > ALCON
> >> > >
> >> > > Can someone pls suggest a way to convert string to integer if/when
> >> > leading
> >> > > blanks are present?
> >> > >
> >> > > My attempts are failing - see attached pdf for more details.
> >> > >
> >> > > Thx in advance
> >> > >
> >> > > Attila
> >> > >
> >> >
> >>
> >
>

Reply via email to