在文档的托管版本中需要额外的数据
Needing additional data in managed Version of documents
我需要管理文档的版本。为此,我正在使用 MarkLogic 的 DataManagement(dls:document-insert-and-manage
和 dls:document-checkout-update-checkin
)。
我正在尝试为本文档的每个版本添加附加数据(例如主要版本、次要版本...)。
据我所知,我无法更改 dls:
版本属性。
使用 dls:document-set-property($uri,<dls:majorversion>1</dls:majorversion>
) 结果是
DLS-SPECIALPROP: (err:FOER0000) Cannot update properties in dls namespace
如何为文档的每个版本添加信息,以便我可以查询它们(例如,给我最新版本的文档,其中 majorversion 等于 1)?
编辑:
我尝试在更新时使用 dls:document-set-property($uri, $prop)
设置属性。
dls:document-checkout('/textdoc/4.xml', fn:true(),"checking out 2",3)
;
dls:document-set-property('/textdoc/4.xml', <mainversion>3</mainversion>),
dls:document-update('/textdoc/4.xml', $doc, "update", fn:true() )
;
dls:document-checkin('/textdoc/4.xml', fn:true())
不幸的是,我无法获取 属性 的历史记录。
使用
let $uri := fn:concat('/textdoc/4.xml')
let $results := for $versionuri in dls:document-version-uris($uri)
return xdmp:document-properties($versionuri)
得到了我 none 的属性。
使用 xdmp:document-properties($uri)
(在文档的基本 uri 上)只会产生我属性的最新内容 (<mainversion>3</mainversion>
)。 属性 主版本的所有先前内容都已丢失。
我没有在 dls 中找到任何检索属性的方法。有房产历史吗?
我是不是漏掉了什么?
DLS 库的设计不适用于主要版本和次要版本,并且对其进行改造并不容易。我现在能想到的最好的办法是将主要版本作为文档 uri 的一部分进行管理,并让 DLS 处理次要版本。然后,您可以使用目录查询来限制文档的主要版本。
您仍然可以尝试使用文档属性,但要避免使用 dls:
前缀。使用你自己的 prefix/namespace,或者根本不用 prefix/namespace。
这样的事情可能会让你接近:
xquery version "1.0-ml";
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
dls:retention-rule-insert(
dls:retention-rule(
"retain-everything",
"Retain all versions of all documents",
(),
(),
"Locate all of the documents",
cts:true-query()
)
)
;
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
let $contents :=
<BOOK>
<TITLE>Baz Goes to the Disco</TITLE>
<CHAPTER1>
<TITLE>Baz Wakes Up to James Brown and Feels Funky</TITLE>
</CHAPTER1>
</BOOK>
return (
dls:document-insert-and-manage(
"/foo/bar/baz.xml",
fn:true(),
$contents
)
)
;
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
dls:document-set-property(
dls:document-version-uri('/foo/bar/baz.xml', 1),
<mainversion>3</mainversion>
)
;
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
let $bazbook :=
<BOOK>
<TITLE>Baz Goes to the Disco</TITLE>
<CHAPTER1>
<TITLE>Baz Wakes Up</TITLE>
<PARA>
Baz woke up this afternoon to the sound of James Brown. Soon
Baz was feeling a little funky, so he put on his cleanest
propeller hat and headed out in search of a Disco.
</PARA>
</CHAPTER1>
</BOOK>
return
dls:document-checkout-update-checkin(
"/foo/bar/baz.xml",
$bazbook,
"Changed the title from Baz Feelin' Funky",
fn:true()
)
;
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
dls:document-set-property(
dls:document-version-uri('/foo/bar/baz.xml', 2),
<mainversion>4</mainversion>
)
HTH!
MarkLogic 9 还支持文档的元数据。您可以在此处存储其他版本信息:https://docs.marklogic.com/xdmp.documentPutMetadata.
我需要管理文档的版本。为此,我正在使用 MarkLogic 的 DataManagement(dls:document-insert-and-manage
和 dls:document-checkout-update-checkin
)。
我正在尝试为本文档的每个版本添加附加数据(例如主要版本、次要版本...)。
据我所知,我无法更改 dls:
版本属性。
使用 dls:document-set-property($uri,<dls:majorversion>1</dls:majorversion>
) 结果是
DLS-SPECIALPROP: (err:FOER0000) Cannot update properties in dls namespace
如何为文档的每个版本添加信息,以便我可以查询它们(例如,给我最新版本的文档,其中 majorversion 等于 1)?
编辑:
我尝试在更新时使用 dls:document-set-property($uri, $prop)
设置属性。
dls:document-checkout('/textdoc/4.xml', fn:true(),"checking out 2",3)
;
dls:document-set-property('/textdoc/4.xml', <mainversion>3</mainversion>),
dls:document-update('/textdoc/4.xml', $doc, "update", fn:true() )
;
dls:document-checkin('/textdoc/4.xml', fn:true())
不幸的是,我无法获取 属性 的历史记录。 使用
let $uri := fn:concat('/textdoc/4.xml')
let $results := for $versionuri in dls:document-version-uris($uri)
return xdmp:document-properties($versionuri)
得到了我 none 的属性。
使用 xdmp:document-properties($uri)
(在文档的基本 uri 上)只会产生我属性的最新内容 (<mainversion>3</mainversion>
)。 属性 主版本的所有先前内容都已丢失。
我没有在 dls 中找到任何检索属性的方法。有房产历史吗?
我是不是漏掉了什么?
DLS 库的设计不适用于主要版本和次要版本,并且对其进行改造并不容易。我现在能想到的最好的办法是将主要版本作为文档 uri 的一部分进行管理,并让 DLS 处理次要版本。然后,您可以使用目录查询来限制文档的主要版本。
您仍然可以尝试使用文档属性,但要避免使用 dls:
前缀。使用你自己的 prefix/namespace,或者根本不用 prefix/namespace。
这样的事情可能会让你接近:
xquery version "1.0-ml";
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
dls:retention-rule-insert(
dls:retention-rule(
"retain-everything",
"Retain all versions of all documents",
(),
(),
"Locate all of the documents",
cts:true-query()
)
)
;
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
let $contents :=
<BOOK>
<TITLE>Baz Goes to the Disco</TITLE>
<CHAPTER1>
<TITLE>Baz Wakes Up to James Brown and Feels Funky</TITLE>
</CHAPTER1>
</BOOK>
return (
dls:document-insert-and-manage(
"/foo/bar/baz.xml",
fn:true(),
$contents
)
)
;
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
dls:document-set-property(
dls:document-version-uri('/foo/bar/baz.xml', 1),
<mainversion>3</mainversion>
)
;
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
let $bazbook :=
<BOOK>
<TITLE>Baz Goes to the Disco</TITLE>
<CHAPTER1>
<TITLE>Baz Wakes Up</TITLE>
<PARA>
Baz woke up this afternoon to the sound of James Brown. Soon
Baz was feeling a little funky, so he put on his cleanest
propeller hat and headed out in search of a Disco.
</PARA>
</CHAPTER1>
</BOOK>
return
dls:document-checkout-update-checkin(
"/foo/bar/baz.xml",
$bazbook,
"Changed the title from Baz Feelin' Funky",
fn:true()
)
;
import module namespace dls = "http://marklogic.com/xdmp/dls"
at "/MarkLogic/dls.xqy";
dls:document-set-property(
dls:document-version-uri('/foo/bar/baz.xml', 2),
<mainversion>4</mainversion>
)
HTH!
MarkLogic 9 还支持文档的元数据。您可以在此处存储其他版本信息:https://docs.marklogic.com/xdmp.documentPutMetadata.