繁体   English   中英

使用MarkLogic Flow Editor分割文档

[英]split document by using MarkLogic Flow Editor

我尝试使用“ 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 () 

通过运行代码段,我报错:

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}

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

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

首先,MarkLogic 8中已弃用了Information Studio。我还建议您大量关注MarkLogic Content Pump的aggregate_record功能:

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!

非常感谢@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. 具有根元素“ docs”的原始文档“ URI = / content / home / admin / Vorlagen / testing / v10.new-ML.xml”

是否可以禁止插入原件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM