Reputation: 12201
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 "1.0-ml"; 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
.
Upvotes: 2
Views: 108
Reputation: 2327
The "arrow operator" =>
is available only starting in version X of MarkLogic (I do not have the exact version at hand, I believe it is somewhere between 8 and 9.)
You can use it in any XQuery "version" supported by MarkLogic (3.1
but also 1.0-ml
). The following two expressions, with and without the arrow operator, produce the exact same result:
(: 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)
If you have only one entry, you can even get rid of the map:new
in the first notation:
map:entry('foo', 1)
,
map:map()
=> map:with('foo', 1)
As mentioned by others, in your particular example, you can simply pass different parameters. But now you know about the arrow operator.
Upvotes: 1
Reputation: 192
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.
Upvotes: 2