使用MarkLogic Flow Editor

时间:2015-06-29 12:57:20

标签: xquery marklogic

我尝试使用" 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>
&#13;
&#13;
&#13;

这是我的&#34; xquery转换&#34;含量:

&#13;
&#13;
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 ()

            
&#13;
&#13;
&#13;

通过运行代码段,我接受错误:

Invalid URI format

及其长篇描述:

&#13;
&#13;
 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
&#13;
&#13;
&#13;

我想,这是&#34;文档设置&#34; in&#34; load&#34; &#34; Flow编辑&#34;

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

但如果我删除它,我会发现同样的错误。

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

2 个答案:

答案 0 :(得分:2)

首先,在MarkLogic 8中不推荐使用Information Studio。我还建议您非常关注MarkLogic内容泵的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!

答案 1 :(得分:0)

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

&#13;
&#13;
           (: 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 :)
&#13;
&#13;
&#13;

好的,现在可以了。这很好,但我发现,加载结束后,我在MarkLogic中看到两个文件:

  1. 我的分裂文件&#34; /rom-data/RD-10-00258.xml"有一个根元素&#34; stwtext&#34; (根据需要)
  2. 来源文件&#34; URI = / content / home / admin / Vorlagen / testing / v10.new-ML.xml&#34;使用根元素&#34; docs&#34;
  3. 是否可以禁止插入原产地文件?