fn:encode-for-uri is much more restrictive. According to the docs it is intended for encoding individual path *components* ... Particularly interesting is that it encodes "/" whereas xdmp:url-encode does not. In general they are reasonably interchangeable ... in that if you want to encode a path component or query component either will work. Or either will take a full URL and turn it into something that doesn't look like a URL such as if you want a link in a URL like
"http://go.to?url={xdmp:url-encode($url)}<http://go.to?url=%7bxdmp:url-encode($url)%7d>" I think what it comes down to is that the fn function is XPath standards compliant and the xdmp function does about the same thing but only the bare minimum leaving more characters unchanged. e.g. try this: let $urls := ("a b" , "http://a.com" , "http://a.com?a=b&c=d" ) for $url in $urls return ( fn:encode-for-uri($url),xdmp:url-encode($url) ) a%20b a+b http%3A%2F%2Fa.com http%3a//a.com http%3A%2F%2Fa.com%3Fa%3Db%26c%3Dd http%3a//a.com%3fa%3db%26c%3dd ----------------------------------------------------------------------------- David Lee Lead Engineer MarkLogic Corporation d...@marklogic.com Phone: +1 650-287-2531 Cell: +1 812-630-7622 www.marklogic.com<http://www.marklogic.com/> This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation. From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of spig Sent: Monday, September 10, 2012 2:48 PM To: general@developer.marklogic.com Subject: [MarkLogic Dev General] fn:encode-for-uri versus xdmp:url-encode This code: xquery version "1.0-ml"; let $url := "test,test1,test2" return ( fn:encode-for-uri($url),xdmp:url-encode($url) ) returns test%2Ctest1%2Ctest2 test,test1,test2 What is the intention of xdmp:url-encode or when would I use one versus the other? Thanks Steve Spigarelli
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general