Visitar URL original
Embedded integer doesn't get represented simply? · Issue #313 · jsonld-java/jsonld-java · GitHub
Skip to content

Embedded integer doesn't get represented simply? #313

Open

Description

@garpinc

I have the following rdf

{
	<http://pk1> a <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#KeySet> , <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#PrimaryKey> ;
		<http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#priority> "6"^^<http://www.w3.org/2001/XMLSchema#int> .
	
	<http://pk2> a <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#KeySet> , <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#PrimaryKey> ;
		<http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#priority> "6"^^<http://www.w3.org/2001/XMLSchema#int> .
	
	<http://testc1> a <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#ClassConcept> , <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#MetadataConcept> , <http://www.w3.org/2004/02/skos/core#Concept> ;
		<http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#primaryKey> <http://pk1> , <http://pk2> .
}

When I run it through json ld via frame I get

{
  "@context" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/ClassConcept",
  "uri" : "http://testc1",
  "type" : [ "metaframe:ClassConcept", "metaframe:MetadataConcept", "skos:Concept" ],
  "primaryKey" : [ {
    "uri" : "http://pk1",
    "type" : [ "metaframe:KeySet", "metaframe:PrimaryKey" ],
    "metaframe:priority" : {
      "type" : "http://www.w3.org/2001/XMLSchema#int",
      "@value" : "5"
    }
  }, {
    "uri" : "http://pk2",
    "type" : [ "metaframe:KeySet", "metaframe:PrimaryKey" ],
    "metaframe:priority" : {
      "type" : "http://www.w3.org/2001/XMLSchema#int",
      "@value" : "6"
    }
  } ]
}

Which does reflect the rdf above... But although metaframe is defined in the @context somehow it remains in the property where the property name should be simply "priority". In addition I would expect it to be instead

"priority" : 6

instead of the type/value object..

Is this a bug?

Activity

  1. changed the title [-]Why do I need to supply the full hierarchy to the frame instead of it being automated?[/-] [+]Embedded integer doesn't get represented simply?[/+] on Apr 12, 2021
  2. afs commented on Apr 12, 2021

    @afs
    Contributor

    instead of the type/value object..

    The input is xsd:int. To use a native JSON number, abbreviation it has to be xsd:integer.

    (The input RDF does not correspond to the output shown. No http://pk2, and the integer is 5.)

  3. garpinc commented on Apr 12, 2021

    @garpinc
    Author
    1. yes.. I added the pk2 in a later iteration. I updated the rdf to reflect matching rdf
    2. Changing it to xsd:integer worked... So awesome but why wouldn't xsd:int work the same way?
    3. "metaframe:priority" is still an issue. Is there a way to resolve that?
  4. afs commented on Apr 12, 2021

    @afs
    Contributor
    1. Because that is the way it's defined : https://www.w3.org/TR/2014/REC-json-ld-api-20140116/#data-round-tripping (and in JSON-LD 1.1 : https://www.w3.org/TR/json-ld-api/#data-round-tripping)
    2. Possible because JSON-LD does not distinguish between the prefix "" and base-relative URIs, meaning a prefix is used ; or because the context has something in it that blocks it; or Object key abbreviation in the presence of JSON numbers. #129.
  5. garpinc commented on Apr 13, 2021

    @garpinc
    Author

    I'm not fully understanding 3.. Is it a bug in jsonld or in my context?

    {
      "@context": {
        "owl" : "http://www.w3.org/2002/07/owl#",
        "xsd" : "http://www.w3.org/2001/XMLSchema#",
        "rdfs" : "http://www.w3.org/2000/01/rdf-schema#",
        "metaframe" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#",
        "uri" : "@id",
        "type" : "@type",
        "allTypes" : {
          "@id" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
          "@type" : "@id",
        },
        "hasKey": {
          "@id": "owl:hasKey",
          "@type": "rdfs:Resource"
        },
        "definedLocation": {
          "@id": "metaframe:definedLocation",
          "@type": "metaframe:Location"
        },
        "priority": {
          "@id": "metaframe:priority",
          "@type": "xsd:integer"
        }
      }
    }
    
  6. gkellogg commented on Apr 13, 2021

    @gkellogg

    The spec defines a useNativeTypes option to the FromRDF algorithm, which will use native numbers for xs:integer and xs:double literals.

  7. gkellogg commented on Apr 13, 2021

    @gkellogg

    The “priority” term will be used only when the resulting string (or native) value matches the term definition.

    it’s useful to take the expanded json and play with it in json-ld.org/playground.

  8. garpinc commented on Apr 13, 2021

    @garpinc
    Author

    I fixed above so that

    {
    	<http://pk1> a <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#KeySet> , <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#PrimaryKey> ;
    		<http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#priority> "6"^^<http://www.w3.org/2001/XMLSchema#integer> .
    	
    	<http://pk2> a <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#KeySet> , <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#PrimaryKey> ;
    		<http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#priority> "6"^^<http://www.w3.org/2001/XMLSchema#integer> .
    	
    	<http://testc1> a <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#ClassConcept> , <http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#MetadataConcept> , <http://www.w3.org/2004/02/skos/core#Concept> ;
    		<http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#primaryKey> <http://pk1> , <http://pk2> .
    }
    

    now gives

    {
      "@context" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/ClassConcept",
      "uri" : "http://testc1",
      "type" : [ "metaframe:ClassConcept", "metaframe:MetadataConcept", "skos:Concept" ],
      "primaryKey" : [ {
        "uri" : "http://pk1",
        "type" : [ "metaframe:KeySet", "metaframe:PrimaryKey" ],
        "metaframe:priority" : 6
      }, {
        "uri" : "http://pk2",
        "type" : [ "metaframe:KeySet", "metaframe:PrimaryKey" ],
        "metaframe:priority" : 6
      } ]
    }
    

    That classconcept context is

    {
      "@context": {
        "skos" : "http://www.w3.org/2004/02/skos/core#",
        "rdfs" : "http://www.w3.org/2000/01/rdf-schema#",
        "metaframe" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#",
        "uri" : "@id",
        "type" : "@type",
        "allTypes" : {
          "@id" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
          "@type" : "@id"
        },
        "altLabel": {
          "@id": "skos:altLabel",
          "@type": "rdfs:Resource"
        },
        "prefLabel": {
          "@id": "skos:prefLabel",
          "@type": "rdfs:Resource"
        },
        "primaryKey": {
          "@id": "metaframe:primaryKey"
        },
        "hiddenLabel": {
          "@id": "skos:hiddenLabel",
          "@type": "rdfs:Resource"
        },
        "broader": {
          "@id": "skos:broader",
          "@type": "rdfs:Resource"
        },
        "narrower": {
          "@id": "skos:narrower",
          "@type": "rdfs:Resource"
        },
        "inScheme": {
          "@id": "skos:inScheme",
          "@type": "rdfs:Resource"
        },
        "definition": {
          "@id": "skos:definition",
          "@type": "rdfs:Resource"
        },
        "matchReference": {
          "@id": "metaframe:matchReference",
          "@type": "metaframe:MatchResult"
        },
        "location": {
          "@id": "metaframe:location",
          "@type": "metaframe:Location"
        },
        "related": {
          "@id": "skos:related",
          "@type": "rdfs:Resource"
        }
      }
    }
    
    

    But the primary key has a type that actually has a different context

    {
      "@context": {
        "owl" : "http://www.w3.org/2002/07/owl#",
        "xsd" : "http://www.w3.org/2001/XMLSchema#",
        "rdfs" : "http://www.w3.org/2000/01/rdf-schema#",
        "metaframe" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#",
        "uri" : "@id",
        "type" : "@type",
        "allTypes" : {
          "@id" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
          "@type" : "@id",
        },
        "hasKey": {
          "@id": "owl:hasKey",
          "@type": "rdfs:Resource"
        },
        "definedLocation": {
          "@id": "metaframe:definedLocation",
          "@type": "metaframe:Location"
        },
        "priority": {
          "@id": "metaframe:priority",
          "@type": "xsd:integer"
        }
      }
    }
    

    if I take the priority field from that context an move it to the classconcept context then it works and i get priority properly..

    So I guess my problem is how to I pass the contexts that I need rather than just the one remote context.. I tried to pass a frame with the property that has the sub context

    {
      "@context" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/ClassConcept",
      "@type" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#ClassConcept",
      "primaryKey" : {
        "@context" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/PrimaryKey",
        "@type" : "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary#PrimaryKey"
      }
    }
    

    But that didn't work..

    I also tried
    "@context" : [ "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/ClassConcept", "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/PrimaryKey" ]

    but that also didn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions