Gert van Valkenhoef created JENA-1031:
-----------------------------------------
Summary: Aliases for data properties not used
Key: JENA-1031
URL: https://issues.apache.org/jira/browse/JENA-1031
Project: Apache Jena
Issue Type: Bug
Components: Jena
Affects Versions: Jena 3.0.0
Environment: Ubuntu 14.04 64bit, IntelliJ IDEA, JDK 8
Reporter: Gert van Valkenhoef
Priority: Minor
When JSON-LD is generated for a graph, the @context will contain property
aliases for all properties used in the graph. However, for properties that have
a data value (rather than a resource), these aliases are not used, and the
properties in the @graph are still their full URIs. This is harmful when the
@context also specifies a data type. For example, doubles can be converted to
integer by accident. The example turtle below results in JSON-LD that when
parsed by Jena is not isomorphic with the graph parsed from turtle (because the
doubleValuedProperty will get an integer value):
{code:title=test.ttl}
<a> <http://www.w3.org/2000/01/rdf-schema#label> "b".
<a> <http://example.com/ontology#doubleValuedProperty> 3.0e1 .
{code}
The JSON-LD as output by Jena:
{code:javascript}
{
"@id" : "http://example.com/a",
"http://example.com/ontology#doubleValuedProperty" : 30.0,
"http://www.w3.org/2000/01/rdf-schema#label" : "b",
"@context" : {
"doubleValuedProperty" : {
"@id" : "http://example.com/ontology#doubleValuedProperty",
"@type" : "http://www.w3.org/2001/XMLSchema#double"
},
"label" : {
"@id" : "http://www.w3.org/2000/01/rdf-schema#label",
"@type" : "http://www.w3.org/2001/XMLSchema#string"
}
}
}
{code}
A failing unit test for round-trip through JSON-LD:
{code:java}
@Test
public void jenaBugTest() throws IOException {
Model model = ModelFactory.createDefaultModel();
model.read(new FileReader("test.ttl"), "http://example.com",
RDFLanguages.strLangTurtle);
StringWriter writer = new StringWriter();
RDFDataMgr.write(writer, model, RDFLanguages.JSONLD);
writer.close();
System.out.println(writer.toString());
Model model2 = ModelFactory.createDefaultModel();
model2.read(new StringReader(writer.toString()), "http://example.com",
RDFLanguages.strLangJSONLD);
assertTrue(model.isIsomorphicWith(model2));
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)