当插入via curl PUT时,MarkLogic正在丢失.xqy文件中的换行符

当插入via curl PUT时,MarkLogic正在丢失.xqy文件中的换行符,marklogic,Marklogic,每当我使用curl添加xquery脚本时,服务器上生成的文件就会丢失所有分页符和一些空白。这会导致行和一些单词一起运行。这会导致脚本失败,因为保留字与其他字连接在一起 我使用的命令是: curl --anyauth --user username:password -X PUT -d @"./badactorasset-lib.xqy" -i -H "Content-type: application/xquery" http://localhost:8004/v1/ext/badactor/b

每当我使用
curl
添加
xquery
脚本时,服务器上生成的文件就会丢失所有分页符和一些空白。这会导致行和一些单词一起运行。这会导致脚本失败,因为保留字与其他字连接在一起

我使用的命令是:

curl --anyauth --user username:password -X PUT -d @"./badactorasset-lib.xqy" -i -H "Content-type: application/xquery" http://localhost:8004/v1/ext/badactor/badactorasset-lib.xqy
当我通过查询控制台浏览MarkLogic服务器上的其他.xqy文件时,这些文件显示的行完全中断。我添加的文件都缺少换行符,看起来不可读

***过去加载到服务器上的另一个文件的示例:

xquery version "1.0-ml";
module namespace ba = "http://marklogic.com/badactor/badactor";
declare option xdmp:mapping "false";
declare variable $ba:ETYPES := ("HX", "FER", "RER", "ELEC", "INSTR");
declare function ba:get-duration($type as xs:string) as xs:yearMonthDuration
{
  let $years :=
    if ($type eq "HX") then 5
    else if ($type eq "FER") then 10
    else if ($type eq "RER") then 2
    else if ($type eq "ELEC") then 10
    else if ($type eq "INSTR") then 2
    else 0
  return xs:yearMonthDuration("P" || fn:string($years) || "Y")
};
xquery version "1.0-ml";module namespace ba = "http://marklogic.com/badactor/badactorasset";declare option xdmp:mapping "false";declare variable $ba:ETYPES := ("HX", "FER", "RER", "ELEC", "INSTR");declare function ba:get-duration($type as xs:string) as xs:yearMonthDuration{  let $years :=    if ($type eq "HX") then 5    else if ($type eq "FER") then 10    else if ($type eq "RER") then 2    else if ($type eq "ELEC") then 10    else if ($type eq "INSTR") then 2    else 0  return xs:yearMonthDuration("P" || fn:string($years) || "Y")};declare function ba:get-threshold($type as xs:string) as xs:integer{   if ($type eq "INST
***服务器上的我的文件示例:

xquery version "1.0-ml";
module namespace ba = "http://marklogic.com/badactor/badactor";
declare option xdmp:mapping "false";
declare variable $ba:ETYPES := ("HX", "FER", "RER", "ELEC", "INSTR");
declare function ba:get-duration($type as xs:string) as xs:yearMonthDuration
{
  let $years :=
    if ($type eq "HX") then 5
    else if ($type eq "FER") then 10
    else if ($type eq "RER") then 2
    else if ($type eq "ELEC") then 10
    else if ($type eq "INSTR") then 2
    else 0
  return xs:yearMonthDuration("P" || fn:string($years) || "Y")
};
xquery version "1.0-ml";module namespace ba = "http://marklogic.com/badactor/badactorasset";declare option xdmp:mapping "false";declare variable $ba:ETYPES := ("HX", "FER", "RER", "ELEC", "INSTR");declare function ba:get-duration($type as xs:string) as xs:yearMonthDuration{  let $years :=    if ($type eq "HX") then 5    else if ($type eq "FER") then 10    else if ($type eq "RER") then 2    else if ($type eq "ELEC") then 10    else if ($type eq "INSTR") then 2    else 0  return xs:yearMonthDuration("P" || fn:string($years) || "Y")};declare function ba:get-threshold($type as xs:string) as xs:integer{   if ($type eq "INST

我错过了什么?为什么我的文件会丢失其结构?

我在一些与MarkLogic无关的文档中发现了这个问题

为了保留换行符,我应该使用“
--data binary
”标志,而不是默认的“
-d
”标志。MarkLogic的网站或他们的任何示例中都没有讨论这一点,但它修复了我的文件

下面是full curl命令:


curl--anyauth--user username:password-X PUT--data binary@./badactorasset lib.xqy“-i-H”内容类型:application/xqueryhttp://localhost:8004/v1/ext/badactor/badactorasset-lib.xqy

一般来说,XQuery对删除换行符并不敏感,就像JavaScript和SPARQL一样,因此,不管怎样,您的代码都应该工作。尽管如此,这里提到了使用--data binary来保留换行符:。