Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test that illustrates float text parse bug #1132

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

mbeckerle
Copy link
Contributor

This is a representation="text" xs:float that is
delimited. Parsing Float.MaxValue i.e., this text string:

3.4028235E38

I get this error:

Parse Error: Value '340282350000000000000000000000000000000' is out of range for type: xs:float

No similar issue for type xs:double.

DAFFODIL-2867

This is a representation="text" xs:float that is
delimited. Parsing Float.MaxValue i.e., this text string:
```
3.4028235E38
```
I get this error:
```
Parse Error: Value '340282350000000000000000000000000000000' is out of range for type: xs:float
```

No similar issue for type xs:double.

DAFFODIL-2867
Copy link
Contributor

@tuxji tuxji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 with a question

<tdml:parserTestCase name="float_text_delim" root="floatTextDelim"
model="SimpleTypes-Embedded.dfdl.xsd" description="Section 5 Simple type-float - DFDL-5-008R">

<tdml:document><![CDATA[3.4028235E38]]></tdml:document>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The document does not end with the terminator (%SP;) expected by the floatTextDelim type. Can you comment on what the implications are?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fields with lengthKind="delimited" can be delimited by more than just separators, including EOF. From the spec:

On parsing, the length of an element with dfdl:lengthKind 'delimited' is determined by scanning the data stream for the delimiter.

The data stream is scanned for any of
· the element's terminator (if specified)
· an enclosing construct's separator or terminator
· the end of an enclosing element designated by its known length
· the end of the data stream

So the dfdl:separator="%SP;" isn't really needed in this case, but it doesn't hurt.

Copy link
Member

@stevedlawrence stevedlawrence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

<tdml:parserTestCase name="float_text_delim" root="floatTextDelim"
model="SimpleTypes-Embedded.dfdl.xsd" description="Section 5 Simple type-float - DFDL-5-008R">

<tdml:document><![CDATA[3.4028235E38]]></tdml:document>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fields with lengthKind="delimited" can be delimited by more than just separators, including EOF. From the spec:

On parsing, the length of an element with dfdl:lengthKind 'delimited' is determined by scanning the data stream for the delimiter.

The data stream is scanned for any of
· the element's terminator (if specified)
· an enclosing construct's separator or terminator
· the end of an enclosing element designated by its known length
· the end of the data stream

So the dfdl:separator="%SP;" isn't really needed in this case, but it doesn't hurt.

@mbeckerle mbeckerle merged commit edf3ca5 into apache:main Jan 2, 2024
10 checks passed
@mbeckerle mbeckerle deleted the daf-2867-float branch January 2, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants