Warm tip: This article is reproduced from stackoverflow.com, please click
marklogic xquery

Xquery giving error on arrow on marklogic qconsole

发布于 2020-04-03 23:42:28

I am trying to do a simple doc insert with the code snippet provided by marklogic.

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"))
);

And this is the error I am getting at the line collection.

[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

.

Questioner
mjosh
Viewed
95
Ashish Patil 2020-01-31 20:57

MarkLogic extension syntax used, XQuery 3.1 apply to (=>) operators are not supported in 1.0-ml mode (these will work fine MarkLogic 9 onwards); I believe you are using MarkLogic 8 or older.

Try using:

        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"
        );

Also, I would suggest you to refer the function signatures for the respective MarkLogic version in MarkLogic docs e.g docs.marklogic.com/8.0/xdmp:document-insert.