首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MarkLogic流编辑器拆分文档

使用MarkLogic流编辑器拆分文档
EN

Stack Overflow用户
提问于 2015-06-29 20:57:20
回答 2查看 151关注 0票数 0

我尝试使用"Information Studio Flow“(MarkLogic v8.0-1.1)拆分传入的文档。问题出在“转换”部分。

这是我的导入单据。为简单起见,我将其内容简化为一个stwtext-element

代码语言:javascript
复制
<docs>
	<stwtext id="RD-10-00258" update="03.2011" seq="RQ-10-00001">
		<head>
			<ti>
				<i>j</i>
			</ti>
			<ff-list>
				<ff id="0103"/>
			</ff-list>
		</head><p>
			Symbol für die
			<vw idref="RD-19-04447">Stromdichte</vw>
			.
		</p>
	</stwtext>
</docs>

这是我的"xquery转换“内容:

代码语言:javascript
复制
xquery version "1.0-ml";

(: Copyright 2002-2015 MarkLogic Corporation.  All Rights Reserved. :)

(:
:: Custom action.  It must be a CPF action module.
:: Replace this text completely, or use it as a template and 
:: add imports, declarations,
:: and code between START and END comment tags.
:: Uses the external variables:
::    $cpf:document-uri: The document being processed
::    $cpf:transition: The transition being executed
:)

import module namespace cpf = "http://marklogic.com/cpf"
   at "/MarkLogic/cpf/cpf.xqy";

(: START custom imports and declarations; imports must be in Modules/ on filesystem :)


(: END custom imports and declarations :)

declare option xdmp:mapping "false";

declare variable $cpf:document-uri as xs:string external;
declare variable $cpf:transition as node() external;

if ( cpf:check-transition($cpf:document-uri,$cpf:transition))
then
    try {
       (: START your custom XQuery here :)
        

       let $doc := fn:doc($cpf:document-uri)
    return 
    xdmp:eval(
              for $wpt in fn:doc($doc)//stwtext
                return 
                  xdmp:document-insert(
                  fn:concat("/rom-data/", fn:concat($wpt/@id,".xml")),
                  $wpt
                  )
            )



       (: END your custom XQuery here :)
       ,
       cpf:success( $cpf:document-uri, $cpf:transition, () )
    }
    catch ($e) {
       cpf:failure( $cpf:document-uri, $cpf:transition, $e, () )
    }
else ()

通过运行代码片段,我接受了以下错误:

代码语言:javascript
复制
Invalid URI format

对它的详细描述:

代码语言:javascript
复制
 XDMP-URI: (err:FODC0005) fn:doc(fn:doc("/8122584828241226495/12835482492021535301/URI=/content/home/admin/Vorlagen/testing/v10.new-ML.xml")) -- Invalid URI format: "&#10;&#9;&#10;&#9; &#10;&#9;&#9;&#10;&#9;&#9;&#9;&#10;&#9;&#9;&#9;&#9;j&#10;&#9;&#9;&#9;&#10;&#9;&#9;&#9;&#10;&#9;&#9;&#9;&#9;&#10;&#9;&#9;&#9;&#10;&#9;&#9;&#10;&#9;&#9;&#10;&#9;&#9;&#9;Symbol f&#252;r die&#10;&#9;&#9;&#9;Stromdichte&#9;&#9;&#9;&#10;&#9;&#9;&#10;&#9;&#10;&#10;&#10;&#10;"
In /18200382103958065126.xqy on line 37
In xdmp:invoke("/18200382103958065126.xqy", (xs:QName("trgr:uri"), "/8122584828241226495/12835482492021535301/URI=/content/home/admi...", xs:QName("trgr:trigger"), ...), <options xmlns="xdmp:eval"><isolation>different-transaction</isolation><prevent-deadlocks>t...</options>)

$doc = fn:doc("/8122584828241226495/12835482492021535301/URI=/content/home/admin/Vorlagen/testing/v10.new-ML.xml")

In /MarkLogic/cpf/triggers/internal-cpf.xqy on line 179
In execute-action("on-state-enter", "http://marklogic.com/states/initial", "/8122584828241226495/12835482492021535301/URI=/content/home/admi...", (xs:QName("trgr:uri"), "/8122584828241226495/12835482492021535301/URI=/content/home/admi...", xs:QName("trgr:trigger"), ...), <options xmlns="xdmp:eval"><isolation>different-transaction</isolation><prevent-deadlocks>t...</options>, (fn:doc("http://marklogic.com/cpf/pipelines/14379829270688061297.xml")/p:pipeline, fn:doc("http://marklogic.com/cpf/pipelines/15861601524191348323.xml")/p:pipeline), fn:doc("http://marklogic.com/cpf/pipelines/15861601524191348323.xml")/p:pipeline/p:state-transition[1]/p:default-action, fn:doc("http://marklogic.com/cpf/pipelines/15861601524191348323.xml")/p:pipeline/p:state-transition[1])

$caller = "on-state-enter"
$state-or-status = "http://marklogic.com/states/initial"
$uri = "/8122584828241226495/12835482492021535301/URI=/content/home/admi..."
$vars = (xs:QName("trgr:uri"), "/8122584828241226495/12835482492021535301/URI=/content/home/admi...", xs:QName("trgr:trigger"), ...)
$invoke-options = <options xmlns="xdmp:eval"><isolation>different-transaction</isolation><prevent-deadlocks>t...</options>
$pipelines = (fn:doc("http://marklogic.com/cpf/pipelines/14379829270688061297.xml")/p:pipeline, fn:doc("http://marklogic.com/cpf/pipelines/15861601524191348323.xml")/p:pipeline)
$action-to-execute = fn:doc("http://marklogic.com/cpf/pipelines/15861601524191348323.xml")/p:pipeline/p:state-transition[1]/p:default-action
$chosen-transition = fn:doc("http://marklogic.com/cpf/pipelines/15861601524191348323.xml")/p:pipeline/p:state-transition[1]
$raw-module-name = "/18200382103958065126.xqy"
$module-kind = "xquery"
$module-name = "/18200382103958065126.xqy"

In /MarkLogic/cpf/triggers/internal-cpf.xqy on line 320

我想,这是“流编辑器”的“加载”部分中的“文档设置”的问题。

代码语言:javascript
复制
URI=/content{$path}/{$filename}{$dot-ext}

但是如果我删除它,我会收到同样的错误。

我不知道该怎么办。我真的是新来的。请帮帮忙

EN

回答 2

Stack Overflow用户

发布于 2015-06-29 21:40:05

首先,Information Studio在MarkLogic 8中已被弃用。我还非常推荐研究一下MarkLogic Content Pump的aggregate_record特性:

http://docs.marklogic.com/guide/ingestion/content-pump#id_65814

除此之外,你的代码还有几个问题。您调用了两次fn:doc,有效地尝试将文档内容解释为uri。有一个不必要的xdmp:eval包装FLWOR语句,它需要一个字符串作为第一个参数。我认为您可以将其缩短为(仅显示动作的内部部分):

代码语言:javascript
复制
   (: START your custom XQuery here :)

   let $doc := fn:doc($cpf:document-uri)
   for $wpt in $doc//stwtext
   return
     xdmp:document-insert(
       fn:concat("/roempp-data/", fn:concat($wpt/@id,".xml")),
       $wpt
     )

   (: END your custom XQuery here :)

哈!

票数 2
EN

Stack Overflow用户

发布于 2015-06-29 23:25:10

非常感谢@grtjn,这就是我的方法。实际上,它是相同的解决方案

代码语言:javascript
复制
           (: START your custom XQuery here :)
            
           xdmp:log(fn:doc($cpf:document-uri), "debug"),
           let $doc := fn:doc($cpf:document-uri)                 

        return 
xdmp:eval('
          declare variable $doc external;
          for $wpt in $doc//stwtext
           return (
                      xdmp:document-insert(
                      fn:concat("/roempp-data/", fn:concat($wpt/@id,".xml")),
                      $wpt,
                      xdmp:default-permissions(),
                      "roempp-data"
                      )
          )'
        ,
(xs:QName("doc"), $doc),
            <options xmlns="xdmp:eval">
                <database>{xdmp:database("roempp-tutorial")}</database>
            </options>

)
    
           (: END your custom XQuery here :)

好了,现在它起作用了。这很好,但是我发现,加载结束后,我在MarkLogic中看到了两个文档:

我的拆分文档“/rom-

  • /RD-10-00258.xml”包含一个根元素"stwtext“(作为带有根元素"docs"

的desired)

  • origin document "URI=/content/home/admin/Vorlagen/testing/v10.new-ML.xml”

是否可以禁止插入文档?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31116351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档