6

我正在使用 MarkLogic 8.0-6.3

sem:rdf-load在使用很少的三元组从 RDF 文件生成三元组时,不会创建。

我已经粘贴了 RDF 文件内容、生成的三元组和我用来加载文件的查询。

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>

三元组

<?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>

询问

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

以下部分不生成三元组

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

我期望输出也低于三倍。

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

请帮助我找到 RDF 中的问题。

4

2 回答 2

4

我同意 MarkLogic 没有正确解析您的 RDF/XML 数据。请联系 MarkLogic 支持以创建此问题的错误报告。

于 2018-06-18T10:58:16.730 回答
4

你能再看看你的RDF,看看它是否正确地传达了你的意思吗?我想你想要一个 skos-abc:classification 对象的匿名节点,它有两个属性,skos-abc:literature 和 skos-abs:classification。在这种情况下,RDF/XML 序列化应该如下:

<?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>

注意使用 rdf:parseType 创建匿名节点。

另一个警告:众所周知,RDF/XML 很难正确。语言中嵌入了许多非 RDF 概念,可以将树转换为图形等。即使需要序列化(本身就是一个符合标准的错误),我建议使用 Turtle、N-triples 或JSON-LD。这是 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 还使匿名节点显式化,这有助于理解底层数据结构:

{
  "@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#"
  }
}

...只是一些随着时间的推移可能会证明有用的建议。

于 2018-06-18T20:23:14.767 回答