使用MLCP的document_selector导出数据时出现语法错误,请求排查
问题原因及解决方法
问题出在-document_selector参数的引号嵌套处理上:
- 你用单引号包裹了整个XQuery表达式,但表达式内部的字符串
'http://foobar.xsd'也用了单引号,shell会错误截断表达式,导致传递给MarkLogic的XQuery语法残缺,触发XDMP-UNEXPECTED错误。
修正后的MLCP命令(两种可选方式)
方式1:转义内部单引号
mlcp.sh export -host xxx.xxx.xxx.xxx -port 8000 -username #### -password ####### \ -mode local -output_file_path ./mlcp_export -database ##### \ -path_namespace 'xsi,http://www.w3.org/2001/XMLSchema-instance' \ -document_selector '/record[@xsi:noNamespaceSchemaLocation eq '\''http://foobar.xsd'\'']'
方式2:外层用双引号包裹表达式
mlcp.sh export -host xxx.xxx.xxx.xxx -port 8000 -username #### -password ####### \ -mode local -output_file_path ./mlcp_export -database ##### \ -path_namespace 'xsi,http://www.w3.org/2001/XMLSchema-instance' \ -document_selector "/record[@xsi:noNamespaceSchemaLocation eq 'http://foobar.xsd']"
说明
- shell中,单引号包裹的字符串内,单引号需要用
'\''转义;若用双引号包裹外层,内部单引号无需转义(双引号允许内部包含单引号)。 - 你的
-path_namespace参数配置是正确的,无需修改。
内容的提问来源于stack exchange,提问作者CJ Chang
相关产品推荐
相关产品推荐

