我有一个内容存储库,其中最新版本的文档使用IsLatestVersion三元组。
这是一个带有isLatestVersion三元组的文档示例。
Document URI: /Transaction/00000000000101000000/1.xml
<aptp:Transaction xmlns:aptp="http://sample.com/aptp">
<aptp:TransactionDate>2016-07-28</aptp:TransactionDate>
<aptp:TransactionType>Principal</aptp:TransactionType>
<aptp:Operation>Buy</aptp:Operation>
<sem:triple name="isLatestVersion"
xmlns:aptp="http://sample.com/aptp"
xmlns:sem="http://marklogic.com/semantics">
<sem:subject datatype="http://www.w3.org/2001/XMLSchema#string">
/Transaction/00000000000101000000/1.xml
</sem:subject>
<sem:predicate>isLatestVersion</sem:predicate>
<sem:object datatype="http://www.w3.org/2001/XMLSchema#boolean">true</sem:object>
</sem:triple>
</aptp:Transaction>
我希望以下代码段返回最新版uris的序列。它目前返回一个空集。
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";
let $uris :=
(
"/Transaction/00000000000101000000/1.xml",
"/Transaction/00000000000101000001/1.xml",
"/Transaction/111111/1.xml"
)
let $query := cts:triple-range-query($uris, "isLatestVersion", fn:true())
return
cts:uris("", (), $query)
我错过了一些明显的东西吗?
答案 0 :(得分:4)
一些想法:
cts:triple-range-query
中省略$ uris。你可以改为传递空序列。"isLatestVersion"
中包含sem:iri
,例如sem:iri("isLatestVersion")
。HTH!
答案 1 :(得分:2)
此代码段效果很好。
declare function local:getLatestUris($uris)
{
let $query := cts:triple-range-query($uris, sem:iri("isLatestVersion"), fn:true())
return cts:uris((), (), $query)
};
local:getLatestUris((
"/Transaction/00000000000101000000/1.xml",
"/Transaction/00000000000101000001/1.xml",
"/Transaction/111111/1.xml"
))