Skip to content

Conversation

@michaeladler
Copy link
Contributor

@michaeladler michaeladler commented Dec 15, 2025

Summary

Implement native parsing support for xsd:float.
Refactor the parsing logic to use a switch-case structure for better readability and maintainability, replacing the previous if-else chain. Integer and double cases are now handled separately, allowing the use of the most suitable standard library parsing methods. This change also eliminates the use of fmt.Sprintf for float-to-integer checks, improving performance.

Basic example

The n-quads

<http://example.com/Subj1> <http://example.com/prop> "1.1E-1"^^<http://www.w3.org/2001/XMLSchema#float> .

should be converted to the following when using native types:

[
  {
    "@id": "http://example.com/Subj1",
    "http://example.com/prop": [
      { "@value": 0.11 }
    ]
  }
]

Motivation

Consistent behavior. It is counterintuitive that double is converted to a native value while float is not. (Unfortunately, xsd:decimal must not be converted, as required by Test t0018.)

Checks

  • Passes make test

Implement native parsing support for xsd:float.
Refactor the parsing logic to use a switch-case structure for better
readability and maintainability, replacing the previous if-else chain.
Integer and double cases are now handled separately, allowing the use of
the most suitable standard library parsing methods. This change also
eliminates the use of fmt.Sprintf for float-to-integer checks, improving
performance.

Signed-off-by: Michael Adler <michael.adler@siemens.com>
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.

1 participant