我处在棘手的情况下,我似乎无法在MarkLogic文档中找到有关它的任何信息。 我遇到的问题是我使用来自不同来源的三元组,并且他们使用不同的方式来描述字符串对象(有些是多语言的):
<http://subject1> <http://www.w3.org/2004/02/skos/core#prefLabel> "Object"^^xs:string .
<http://subject2> <http://www.w3.org/2004/02/skos/core#prefLabel> "Object"@en .
所以当我做的时候
cts:triples((), sem:iri("http://www.w3.org/2004/02/skos/core#prefLabel"), "Object")
然后我才得到第一个三联。
问题是,如何让它忽略语言并返回两个三元组(如果可能,不使用sparql)?
答案 0 :(得分:5)
有趣的是使用&#34; Object&#34;像上面一样,我根本没有返回结果(在MacOS上使用MarkLogic 7.0-4.1)。相反,我不得不使用:
cts:triples((),(),(
sem:unknown("Object", sem:iri("http://www.w3.org/2001/XMLSchemastring")),
rdf:langString("Object", "en")
))
这里有一些较长的代码可以在QConsole中运行(针对空数据库运行!)以更好地了解发生了什么:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
sem:rdf-insert(sem:rdf-parse('
@prefix xs: <http://www.w3.org/2001/XMLSchema> .
<http://subject1> <http://www.w3.org/2004/02/skos/core#prefLabel> "Object"^^xs:string .
<http://subject2> <http://www.w3.org/2004/02/skos/core#prefLabel> "Object"@en .
', "turtle"))
;
'all triples:',
cts:triples((),(),()),
'all objects:',
for $triple in cts:triples((),(),())
return xdmp:describe(sem:triple-object($triple)),
'all object languages:',
for $triple in cts:triples((),(),())
return concat('"', sem:lang(sem:triple-object($triple)), '"'),
'results with "Object":',
cts:triples((),(),sem:iri("Object")),
'results with sem:unknown("Object", sem:iri("xs:string")):',
cts:triples((),(),sem:unknown("Object", sem:iri("xs:string"))),
'results with sem:unknown("Object", sem:iri("http://www.w3.org/2001/XMLSchemastring")):',
cts:triples((),(),sem:unknown("Object", sem:iri("http://www.w3.org/2001/XMLSchemastring"))),
'results with rdf:langString("Object", "en")',
cts:triples((),(),rdf:langString("Object", "en")),
'combined results:',
cts:triples((),(),(
sem:unknown("Object", sem:iri("http://www.w3.org/2001/XMLSchemastring")),
rdf:langString("Object", "en")
))
HTH!