我们有一个相当简单的 XQuery 和 Groovy 代码,如下所示。查询代码:
declare variable $criteria as element(criteria) external ;
<scopedInterventions>{
$criteria/equals/field
}</scopedInterventions>
这是试图调用它的测试代码
def uri = new URI("xcc://admin:admin@localhost:8001")
def contentSource = ContentSourceFactory.newContentSource(uri)
def request = session.newModuleInvoke("ourQuery.xqy")
def criteria =
"""<criteria>
<equals>
<field>status</field>
<value>draft</value>
</equals>
</criteria>
"""
request.setNewVariable("criteria",ValueType.ELEMENT, criteria);
session.submitRequest(request).asString()
}
我们在执行时收到此错误:
引起:com.marklogic.xcc.exceptions.XQueryException: XDMP-LEXVAL: xs:QName("element()") -- 无效的词法值 "element()" [Session: user=admin, cb={default} [ ContentSource: user=admin, cb={none} [provider: address=localhost/127.0.0.1:9001, pool=1/64]]] [Client: XCC/5.0-3, Server: XDBC/5.0-3] expr : xs:QName("element()") at com.marklogic.xcc.impl.handlers.ServerExceptionHandler.handleResponse(ServerExceptionHandler.java:34) at com.marklogic.xcc.impl.handlers.EvalRequestController.serverDialog(EvalRequestController.java :83) com.marklogic.xcc.impl.handlers.AbstractRequestController.runRequest(AbstractRequestController.java:84) com.marklogic.xcc.impl.SessionImpl.submitRequestInternal(SessionImpl.java:373) com.marklogic.xcc。 impl.SessionImpl.submitRequest(SessionImpl.java:356) 在 com.zynx.galen.dataaccess.MarkLogicUtilities.executeQueryWithMultipleXMLParameters(MarkLogicUtilities.groovy:52) 在 com.zynx.galen.repositories.ScopedInterventionService.getScopedInterventionsByCriteria(ScopedInterventionService.groovy:20) ... 还有 1 个
任何帮助将不胜感激。