我正在使用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中的问题。
答案 0 :(得分:4)
我同意MarkLogic没有正确解析您的RDF / XML数据。请联系MarkLogic支持人员以创建此问题的错误报告。
答案 1 :(得分: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#"
}
}
......只是一些可能随着时间的推移而有用的建议。