简体   繁体   中英

What is xdmp:value??? XQuery, MarkLogic

I learned xdmp:value function.

Use like this

let $var := 5
return xdmp:value($var)

Then, I get 5.

What is difference when I write this:

let $var := 5
return $var

I also get 5 here. Maybe I miss some points.

Please explain this function.

THANKS IN ADVANCE.

There's really no difference if you use xdmp:value() or not in your example. Although I'd caution against using xdmp:value() unnecessarily in order to maximize your query performance.

One of the most common use cases for xdmp:value() is to evaluate a string of text as code without losing context (such as you would with xdmp:eval()).

For example:

let $x := 1
return xdmp:value("$x + 1")

Another common use case for xdmp:value() is to integrate a variable into an XPath expression dynamically.

For example:

/path/to/mystery/element/xdmp:value($elementName)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM