TelicentPaul opened a new pull request, #2301:
URL: https://github.com/apache/jena/pull/2301
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.
----
- [x] Tests are included.
- [x] Documentation change and updates are provided for the [Apache Jena
website](https://github.com/apache/jena-site/)
- [x] Commits have been squashed to remove intermediate development commit
messages.
- [x] 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](https://www.apache.org/licenses/contributor-agreements.html).
----
See the [Apache Jena "Contributing"
guide](https://github.com/apache/jena/blob/main/CONTRIBUTING.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]