XDMP-NONMIXED complexcont 在 REST 扩展中执行 xpath 时



我正在尝试执行以下操作

import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";     
let $options := <options xmlns="http://marklogic.com/appservices/search">
                    <additional-query>
                        <cts:collection-query xmlns:cts="http://marklogic.com/cts">
                            <cts:uri>http://ir.abbvienet.com/content-repo/type/envelope</cts:uri>
                        </cts:collection-query>
                    </additional-query>
                    <constraint name="gene">
                        <range type="xs:string" facet="true">
                            <path-index>//Hit[@type='GENE']/@id</path-index>
                            <facet-option>frequency-order</facet-option>
                            <facet-option>descending</facet-option>
                            <facet-option>limit=10</facet-option>
                        </range>
                    </constraint>
                </options>
    return
    $options//search:constraint[@name='gene']
当我

在查询控制台中执行此操作时,它工作正常..但是当我在REST扩展中执行相同的操作时,出现以下错误

<error:xquery-version>1.0-ml</error:xquery-version>
<error:message>Node has complex type with non-mixed complex content</error:message>
<error:format-string>XDMP-NONMIXEDCOMPLEXCONT: fn:data(&lt;constraint name="gene" xmlns="http://marklogic.com/appservices/search"&gt;&lt;range type="xs:string" facet="true"&gt;&lt;path-index&gt;//Hit[@type='GE...&lt;/constraint&gt;) -- Node has complex type with non-mixed complex content</error:format-string>
 <error:retryable>false</error:retryable>
<error:expr>fn:data(&lt;constraint name="gene" xmlns="http://marklogic.com/appservices/search"&gt;&lt;range type="xs:string" facet="true"&gt;&lt;path-index&gt;//Hit[@type='GE...&lt;/constraint&gt;)</error:expr>
 <error:data/>
<error:stack>

关于为什么会这样的任何想法?

编辑 在下面添加了我的 REST 扩展

*********
module namespace repoTest = "http://marklogic.com/rest-api/resource/repoTest";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
declare default function namespace  "http://www.w3.org/2005/xpath-functions";
declare option xdmp:mapping "false";
(: Function responding to GET method - must use local name 'get':)
declare function repoTest:get($context as map:map, $params  as map:map) as document-node()*
{
        let $out :=
            try{
            let $options := <options xmlns="http://marklogic.com/appservices/search">
                                <constraint name="gene">
                                    <range type="xs:string" facet="true">
                                        <path-index>//Hit[@type='GENE']/@id</path-index>
                                        <facet-option>frequency-order</facet-option>
                                        <facet-option>descending</facet-option>
                                        <facet-option>limit=10</facet-option>
                                    </range>
                                </constraint>
                    </options>
            let $facetContraint :=  $options//search:constraint[@name='gene']
            let $_ := xdmp:log("facetContraint :" || $facetContraint)
                return $facetContraint
            }catch($ex) {
                let $log := xdmp:log("ERROR !!!!!")
                let $log := xdmp:log($ex)
                return ()
        }
    return document { $out }
};
(: Function responding to PUT method - must use local name 'put'. :)
declare function repoTest:put($context as map:map, $params  as map:map, $input as document-node()*) as document-node()?
{
    repoTest:notSupportedMsg($context)
};
(: Func responding to DELETE method - must use local name 'delete'. :)
declare function repoTest:delete($context as map:map,$params  as map:map) as document-node()?
{
    repoTest:notSupportedMsg($context)
};
(: Function responding to POST method - must use local name 'post'. :)
declare function repoTest:post($context as map:map, $params  as map:map,$input   as document-node()*) as document-node()*
{
    repoTest:notSupportedMsg($context)
};
declare private function repoTest:notSupportedMsg($context as map:map) as document-node()*
{
    let $_ := map:put($context, "output-status", (501, "Not Supported HTTP method"))
    let $output := json:object()
    let $errorResponse := json:object()
    let $_ := (
        map:put($errorResponse, "statusCode", 501),
        map:put($errorResponse, "message", "Not Supported HTTP method")
    )
    let $dummpy := map:put($output, "errorResponse", $errorResponse )
    return document {xdmp:to-json($output)}
};

我能够解决我的问题,但不明白为什么这会发生在 Rest 扩展中而不是在查询控制台中。

在 REST 扩展中,由于$options的默认命名空间,它失败了,一旦删除它就可以工作了.. 我删除的方式是

functx:change-element-ns-deep($options, '','')

如果有人可以解释为什么我在问题中的代码可以在查询控制台中工作,但在 REST 扩展中不起作用,那就太好了,

最新更新