From e53b8f638dcc2378d096d5c13575a411d2b6ee15 Mon Sep 17 00:00:00 2001 From: creanjx Date: Fri, 27 Sep 2019 10:19:02 +0200 Subject: [PATCH] #333 fix syntax error in xdmp:unpath call arises when entity definition has a flat stucture - existing code strips out the last path component resulting in an empty path being passed to xdmp:unpath --- .../survivorship/merging/base.xqy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/ml-modules/root/com.marklogic.smart-mastering/survivorship/merging/base.xqy b/src/main/ml-modules/root/com.marklogic.smart-mastering/survivorship/merging/base.xqy index 6c6f00f..0a7ad9c 100644 --- a/src/main/ml-modules/root/com.marklogic.smart-mastering/survivorship/merging/base.xqy +++ b/src/main/ml-modules/root/com.marklogic.smart-mastering/survivorship/merging/base.xqy @@ -1575,7 +1575,12 @@ declare function merge-impl:get-instance-props-by-path( let $inst-path := merge-impl:strip-top-path($path-prop/@path) let $parts := fn:tokenize($inst-path, "/") (: We'll grab the node above our target so that we determine whether it's an array :) - let $middle-path := fn:string-join($parts[fn:position() != fn:last()], "/") + + (:Issue #333 WORKAROUND:) + let $middle-path := if (fn:count($parts) eq 1) then $parts[fn:last()] + else fn:string-join($parts[fn:position() != fn:last()], "/") + (:Issue #333 END OF WORKAROUND:) + let $target-name-str := $parts[fn:last()] let $target-name := fn:QName(map:get($ns-map, fn:replace($target-name-str, ":.*", "")), $target-name-str) return (