在文档的受管版本中需要其他数据

时间:2019-01-28 06:32:59

标签: marklogic

我需要管理文档的版本。为此,我使用了MarkLogic的DataManagement(dls:document-insert-and-managedls:document-checkout-update-checkin)。

我正在尝试为该文档的每个版本提供其他数据(例如majorversion,minorversion等)。 据我所知,我无法更改dls:版本属性。 使用dls:document-set-property($uri,<dls:majorversion>1</dls:majorversion>)会导致

  

DLS-SPECIALPROP:(err:FOER0000)无法更新dls命名空间中的属性

如何为文档的每个版本添加信息,以便查询(例如,给我最新版本的主版本等于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)

没有我的财产。

使用xdmp:document-properties($uri)(基于文档的基本uri)只会得到我属性的最新内容(<mainversion>3</mainversion>)。以前所有用于属性维护版本的内容都将丢失。

我没有发现任何检索dls属性的方法。有物业的历史吗?

我想念什么吗?

2 个答案:

答案 0 :(得分:2)

DLS库不适用于主要版本和次要版本,对其进行改装也不容易。我现在能想到的最好的办法是,将主要版本作为文档uri的一部分进行管理,并让DLS处理次要版本。然后,您可以使用目录查询将文档限制为主要版本。

您仍然可以继续使用文档属性,但是避免使用dls:前缀。使用您自己的前缀/名称空间,或者根本不使用前缀/名称空间。

这样的事情可能会让你接近:

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!

答案 1 :(得分:2)

MarkLogic 9还支持文档的元数据。您可以在此处存储其他版本信息:https://docs.marklogic.com/xdmp.documentPutMetadata

相关问题