Skip to content

GH-2270: Properly process objects passed in as xsd:string literals.#2301

Merged
rvesse merged 1 commit intoapache:mainfrom
TelicentPaul:bug/gh2270_handle_objects_passed_as_string_type
Feb 29, 2024
Merged

GH-2270: Properly process objects passed in as xsd:string literals.#2301
rvesse merged 1 commit intoapache:mainfrom
TelicentPaul:bug/gh2270_handle_objects_passed_as_string_type

Conversation

@TelicentPaul
Copy link
Copy Markdown
Contributor

GitHub issue resolved #2270

Pull request Description:
As illustrated in the sample code on the linked issue, when creating literal nodes of xsd:string type we are not converting the given objects to Strings but rather are leaving them as the original classes. Instead of UUIDs, the same effect can be made if passed Integers, Floats or any other object type.
NodeFactory.createLiteralByValue(UUID.randomUUID(), XSDDatatype.XSDstring); NodeFactory.createLiteralByValue(9, XSDDatatype.XSDstring); NodeFactory.createLiteralByValue(9.99f, XSDDatatype.XSDstring);
What's interesting is that for numeric types, this isn't the case and if passing a (valid) string to numeric type everything works as expected.
NodeFactory.createLiteralByValue("9", XSDDatatype.XSDint); NodeFactory.createLiteralByValue("9.99", XSDDatatype.XSDfloat);

The fix is relatively simple. When processing the canonised form (using the "cannonicalise" (sic) method) of the XSDBaseStringType the original value is being returned. By contrast, if you look at the equivalent XSDBaseNumericType the value is converted into the appropriate type.

To that end, I've added some tests to illustrate this by creating both string and numerical literal nodes passing in differing classes.


  • Tests are included.
  • Documentation change and updates are provided for the Apache Jena website
  • Commits have been squashed to remove intermediate development commit messages.
  • Key commit messages start with the issue number (GH-xxxx, or if in JIRA, JENA-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

Copy link
Copy Markdown
Member

@rvesse rvesse left a comment

Choose a reason for hiding this comment

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

LGTM, can you please squash into a single commit?

@TelicentPaul
Copy link
Copy Markdown
Contributor Author

Of course. For future reference, you can enable that within Pull Request themselves to remove manual steps, which can be potentially error prone in my experience. I'll also rebase the branch too while I'm at it.

https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/configuring-commit-squashing-for-pull-requests

@TelicentPaul TelicentPaul force-pushed the bug/gh2270_handle_objects_passed_as_string_type branch from 39d55ec to 26e0207 Compare February 28, 2024 15:36
@afs
Copy link
Copy Markdown
Member

afs commented Feb 28, 2024

Please use "squash and merge" with care - the commit message isn't going to be great (requires human checking) and the merge is often being done by a different person to the contributor.

@rvesse rvesse merged commit 5103444 into apache:main Feb 29, 2024
@TelicentPaul TelicentPaul deleted the bug/gh2270_handle_objects_passed_as_string_type branch February 29, 2024 11:09
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.

UUID formated string cannot be found

4 participants