【问题标题】:Xquery giving error on arrow on marklogic qconsoleXquery在marklogic qconsole上的箭头上给出错误
【发布时间】:2020-01-31 00:37:16
【问题描述】:

我正在尝试使用 marklogic 提供的代码 sn-p 进行简单的文档插入。

xdmp:document-insert("/test/shipment1.xml", <shiporder orderid="889923">
  <orderperson>John Smith</orderperson>
  <shipto>
    <name>Ola Nordmann</name>
    <address>Langgt 23</address>
    <city value="BangaloreHighway">>4000 Stavanger</city>
    <country>Norway</country>
  </shipto>
  <item>
    <title>Empire Burlesque</title>
    <note>Special Edition</note>
<var>Special Edition in the industry</var>

    <quantity>1</quantity>
    <price>10.90</price>
  </item>
  <item>
    <title>Hide your heart</title>
    <quantity>1</quantity>
    <price>9.90</price>
  </item>
</shiporder>,  

map:map() => map:with("collections", ("PRACTICE"))
);

这是我在行集合时遇到的错误。

[1.0-ml] XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Gt_, expecting Function30_ or Percent_
Stack Trace
At line 32 column 11:
In xdmp:eval("xquery version &quot;1.0-ml&quot;;&#10;declare namespace html = ...", (), <options xmlns="xdmp:eval"><database>14078695328357470008</database><modules>99880860359119...</options>)

30. </shiporder>,
31.
32. map:map() => map:with("collections", ("PRACTICE"))
33. );
34

.

【问题讨论】:

  • 在 9.0-11 中运行良好。你的城市标签中确实有一个额外的&gt;..

标签: xquery marklogic


【解决方案1】:

MarkLogic extension syntax used, XQuery 3.1 apply to (=>) 运算符在1.0-ml 模式下不受支持(这些将在 MarkLogic 9 及更高版本中正常工作);我相信您使用的是MarkLogic 8 或更早版本。

尝试使用:

        xdmp:document-insert
        (
            "/test/shipment1.xml"
            , 
            <shiporder orderid="889923">
                <orderperson>John Smith</orderperson>
                <shipto>
                    <name>Ola Nordmann</name>
                    <address>Langgt 23</address>
                    <city value="BangaloreHighway">>4000 Stavanger</city>
                    <country>Norway</country>
                </shipto>
                <item>
                    <title>Empire Burlesque</title>
                    <note>Special Edition</note>
                    <var>Special Edition in the industry</var>
                    <quantity>1</quantity>
                    <price>10.90</price>
                </item>
                <item>
                    <title>Hide your heart</title>
                    <quantity>1</quantity>
                    <price>9.90</price>
                </item>
            </shiporder>
            ,  
            xdmp:default-permissions()
            ,
            "PRACTICE"
        );

另外,我建议您参考 MarkLogic 文档中各个 MarkLogic 版本的函数签名,例如 docs.marklogic.com/8.0/xdmp:document-insert

【讨论】:

    【解决方案2】:

    “箭头运算符”=&gt; 仅在 MarkLogic X 版本中可用(我手头没有确切的版本,我相信它在 8 到 9 之间。)

    您可以在 MarkLogic 支持的任何 XQuery“版本”中使用它(3.1 也可以是1.0-ml)。以下两个表达式,带和不带箭头运算符,产生完全相同的结果:

    (: if you use 3.1 instead, you need to declare the namespace prefix "map" :)
    xquery version "1.0-ml";
    
    map:new((
      map:entry('foo', 1),
      map:entry('bar', 2)))
    ,
    map:map()
      => map:with('foo', 1)
      => map:with('bar', 2)
    

    如果你只有一个条目,你甚至可以去掉第一个符号中的map:new

    map:entry('foo', 1)
    ,
    map:map()
      => map:with('foo', 1)
    

    正如其他人所提到的,在您的特定示例中,您可以简单地传递不同的参数。但是现在您知道箭头运算符了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      • 1970-01-01
      • 2017-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多