Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triples are not generated as expected from RDF file

I am using MarkLogic 8.0-6.3

While generating triples from an RDF file using sem:rdf-load few of the triples are not created.

I have pasted the RDF file content, generated triples and the query which I am using to load the file.

RDF

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:skos="http://www.w3.org/2004/02/skos/core#"
         xmlns:skos-abc="http://www.abccustom.com#"
         xmlns:dc="http://purl.org/dc/elements/1.1/">
    <skos:Concept rdf:about="http://www.mla.com/work/W19622_2">
        <skos-abc:createdDate>5/10/2004 12:13:25 PM</skos-abc:createdDate>
        <skos-abc:classification>
            <skos-abc:literature>Netherlandic literature</skos-abc:literature>
            <skos-abc:timePeriod>1900-1999</skos-abc:timePeriod>
        </skos-abc:classification>
        <skos-abc:genreName>poetry</skos-abc:genreName>
    </skos:Concept>
</rdf:RDF>

Triples

<?xml version="1.0" encoding="UTF-8"?>
<sem:triples xmlns:sem="http://marklogic.com/semantics">
    <sem:triple>
        <sem:subject>http://www.mla.com/work/W19622_2</sem:subject>
        <sem:predicate>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</sem:predicate>
        <sem:object>http://www.w3.org/2004/02/skos/core#Concept</sem:object>
    </sem:triple>
    <sem:triple>
        <sem:subject>http://www.mla.com/work/W19622_2</sem:subject>
        <sem:predicate>http://www.abccustom.com#createdDate</sem:predicate>
        <sem:object datatype="http://www.w3.org/2001/XMLSchema#string">5/10/2004 12:13:25 PM</sem:object>
    </sem:triple>
    <sem:triple>
        <sem:subject>http://www.mla.com/work/W19622_2</sem:subject>
        <sem:predicate>http://www.abccustom.com#classification</sem:predicate>
        <sem:object>http://marklogic.com/semantics/blank/3225438043493348960</sem:object>
    </sem:triple>
    <sem:triple>
        <sem:subject>http://marklogic.com/semantics/blank/3225438043493348960</sem:subject>
        <sem:predicate>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</sem:predicate>
        <sem:object>http://www.abccustom.com#literature</sem:object>
    </sem:triple>
    <sem:triple>
        <sem:subject>http://www.mla.com/work/W19622_2</sem:subject>
        <sem:predicate>http://www.abccustom.com#classification</sem:predicate>
        <sem:object>http://marklogic.com/semantics/blank/6756667330843774627</sem:object>
    </sem:triple>
    <sem:triple>
        <sem:subject>http://marklogic.com/semantics/blank/6756667330843774627</sem:subject>
        <sem:predicate>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</sem:predicate>
        <sem:object>http://www.abccustom.com#timePeriod</sem:object>
    </sem:triple>
    <sem:triple>
        <sem:subject>http://www.mla.com/work/W19622_2</sem:subject>
        <sem:predicate>http://www.abccustom.com#genreName</sem:predicate>
        <sem:object datatype="http://www.w3.org/2001/XMLSchema#string">poetry</sem:object>
    </sem:triple>
</sem:triples>

Query

sem:rdf-load("D:\Projects\MLA\SKOS sample\work1.rdf", ("graph=thesaurus-work1"));

Triples aren't generated for below part

<skos-abc:classification>
    <skos-abc:literature>Netherlandic literature</skos-abc:literature>
    <skos-abc:timePeriod>1900-1999</skos-abc:timePeriod>
</skos-abc:classification>

I was expecting below triples as well in the output.

Sub: http://marklogic.com/semantics/blank/3225438043493348960
Pred: literature
Obj: Netherlandic literature
--------------------------------------
Sub: http://marklogic.com/semantics/blank/6756667330843774627
Pred: timePeriod
Obj: 1900-1999

Please help me in finding the problem in RDF.

like image 379
Dixit Singla Avatar asked Jun 15 '18 13:06

Dixit Singla


2 Answers

Could you take another look at your RDF to see if it correctly conveys your meaning? I think you want an anonymous node for the object of skos-abc:classification, with two properties, skos-abc:literature and skos-abs:classification. In that case, the RDF/XML serialization should be the following:

<?xml version="1.0"?>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:skos-abc="http://www.abccustom.com#"
    xmlns:skos="http://www.w3.org/2004/02/skos/core#">
  <skos:Concept rdf:about="http://www.mla.com/work/W19622_2">
    <skos-abc:classification rdf:parseType="Resource">
      <skos-abc:literature>Netherlandic literature</skos-abc:literature>
      <skos-abc:timePeriod1>1900-1999</skos-abc:timePeriod1>
    </skos-abc:classification>
    <skos-abc:createdDate>5/10/2004 12:13:25 PM</skos-abc:createdDate>
  </skos:Concept>
</rdf:RDF>

Note the use of rdf:parseType for creating the anonymous node.

An additional caveat: RDF/XML is notoriously difficult to get correct. There are lots of non-RDF concepts embedded in the language to turn trees into graphs, etc. Even if that serialization is required (a standards-compliance bug in and of itself), I'd suggest using Turtle, N-triples, or JSON-LD. Here's the example in Turtle:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skos-abc: <http://www.abccustom.com#> .
<http://www.mla.com/work/W19622_2>
  rdf:type skos:Concept ;
  skos-abc:classification [
      skos-abc:literature "Netherlandic literature" ;
      skos-abc:timePeriod1 "1900-1999" ;
    ] ;
  skos-abc:createdDate "5/10/2004 12:13:25 PM" ;
.

JSON-LD also makes the anonymous node explicit, which helps understand the underlying data structure:

{
  "@graph" : [ {
    "@id" : "_:b0",
    "literature" : "Netherlandic literature",
    "timePeriod1" : "1900-1999"
  }, {
    "@id" : "http://www.mla.com/work/W19622_2",
    "@type" : "skos:Concept",
    "classification" : "_:b0",
    "createdDate" : "5/10/2004 12:13:25 PM"
  } ],
  "@context" : {
    "literature" : {
      "@id" : "http://www.abccustom.com#literature"
    },
    "timePeriod1" : {
      "@id" : "http://www.abccustom.com#timePeriod1"
    },
    "classification" : {
      "@id" : "http://www.abccustom.com#classification",
      "@type" : "@id"
    },
    "createdDate" : {
      "@id" : "http://www.abccustom.com#createdDate"
    },
    "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    "skos-abc" : "http://www.abccustom.com#",
    "dcterms" : "http://purl.org/dc/terms/",
    "skos" : "http://www.w3.org/2004/02/skos/core#"
  }
}

...just some suggestions that may prove useful over time.

like image 133
scotthenninger Avatar answered Sep 19 '22 02:09

scotthenninger


I agree that your RDF/XML data is not being parsed correctly by MarkLogic. Please contact MarkLogic support to create a bug report for this issue.

like image 32
John Snelson Avatar answered Sep 20 '22 02:09

John Snelson