【问题标题】:split document by using MarkLogic Flow Editor使用 MarkLogic 流编辑器拆分文档
【发布时间】:2015-06-29 12:57:20
【问题描述】:

我尝试使用“Information Studio Flows”(MarkLogic v 8.0-1.1)拆分传入的文档。问题出在“转换”部分。

这是我的导入文件。为简单起见,我将其内容减少为一个 stwtext-element

<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 转换”内容:

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 ()

            

通过运行 sn-p,我得到了错误:

Invalid URI format

及其详细描述:

 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

我以为是“流程编辑器”的“加载”部分中的“文档设置”有问题

URI=/content{$path}/{$filename}{$dot-ext}

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

我不知道该怎么做。我真的很新。请帮忙

【问题讨论】:

    标签: xquery marklogic


    【解决方案1】:

    首先,Information Studio 在 MarkLogic 8 中已被弃用。我还建议非常关注 MarkLogic 内容泵的聚合记录功能:

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

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

       (: 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 :)
    

    HTH!

    【讨论】:

    • 非常感谢!我现在也想通知您我的代码中的这个错误。我采取了其他方法
    • 对于您关于“信息工作室”已弃用的评论,这对我来说是新的,但没关系。但在我尝试使用“Information Studio”解决问题之前,我确实尝试使用 mlcp 来解决问题。我不确定,但对于我的问题,mlcp 中可能存在错误。我将在其他“询问”中发布它
    • 所以,这是与 mlcp stackoverflow.com/questions/31120344/… 拆分的问题
    【解决方案2】:

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

               (: 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 中看到了两个文档:

    1. 我的拆分文档“/rom-data/RD-10-00258.xml”带有一个根元素“stwtext”(根据需要)
    2. origin 带有根元素“docs”的文档“URI=/content/home/admin/Vorlagen/testing/v10.new-ML.xml”

    是否可以禁止插入origin文档?

    【讨论】:

    • 您不能禁止插入原始文档,因为插入本身会激活此操作。不过我想你可以删除它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-04
    • 2010-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多