You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2015/09/18 19:58:04 UTC
[jira] [Commented] (JENA-1031) Aliases for data properties not used
[ https://issues.apache.org/jira/browse/JENA-1031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14876058#comment-14876058 ]
Andy Seaborne commented on JENA-1031:
-------------------------------------
I'm not seeing quite the same thing as you (strictly this is with Jena development master):
The models are not isomorphic because "3.0e1" becomes "3.0E1".
Changing {{test.ttl}} from {{3.0e1}} to {{3.0E1}} and they are isomorphic.
Jena uses [jsonld-java|https://github.com/jsonld-java/] for JSON-LD support.
It looks like it is the way jsonld-java is round-tripping numbers.
And some JSON-LD does not round trip because of JSON "interesting" treatment of numbers.
{code}
public void jenaBugTest() throws IOException {
Model model = RDFDataMgr.loadModel("/home/afs/tmp/test.ttl") ;
StringWriter writer = new StringWriter();
RDFDataMgr.write(writer, model, RDFLanguages.JSONLD);
writer.close();
Model model2 = ModelFactory.createDefaultModel();
model2.read(new StringReader(writer.toString()), "http://example.com", RDFLanguages.strLangJSONLD);
System.out.println("----JSONLD model:");
RDFDataMgr.write(System.out, model, RDFLanguages.JSONLD);
System.out.println("----JSONLD model2:");
RDFDataMgr.write(System.out, model, RDFLanguages.JSONLD);
System.out.println("----Turtle model:") ;
RDFDataMgr.write(System.out, model, RDFLanguages.TTL);
System.out.println("----Turtle model2:") ;
RDFDataMgr.write(System.out, model2, RDFLanguages.TTL);
System.out.println("---------");
System.out.println("Isomorphic? "+model.isIsomorphicWith(model2)) ;
}
{code}
{code}
----JSONLD model:
{
"@id" : "file:///home/afs/tmp/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"
}
}
}
----JSONLD model2:
{
"@id" : "file:///home/afs/tmp/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"
}
}
}
----Turtle model:
<file:///home/afs/tmp/a>
<http://www.w3.org/2000/01/rdf-schema#label>
"b" ;
<http://example.com/ontology#doubleValuedProperty>
3.0e1 .
----Turtle model2:
<file:///home/afs/tmp/a>
<http://www.w3.org/2000/01/rdf-schema#label>
"b" ;
<http://example.com/ontology#doubleValuedProperty>
3.0E1 .
---------
Isomorphic? false
{code}
> 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)