未按预期从 RDF 文件生成三元组
Triples are not generated as expected from RDF file
我正在使用 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中的问题。
我同意您的 RDF/XML 数据未被 MarkLogic 正确解析。请联系 MarkLogic 支持部门以针对此问题创建错误报告。
您能否再看一下您的 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#"
}
}
...只是一些随着时间的推移可能会证明有用的建议。
我正在使用 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中的问题。
我同意您的 RDF/XML 数据未被 MarkLogic 正确解析。请联系 MarkLogic 支持部门以针对此问题创建错误报告。
您能否再看一下您的 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#"
}
}
...只是一些随着时间的推移可能会证明有用的建议。