I am trying to do a node replace in a document of a specified URI and specified xpath expression.
Tried to do eval to get old-element based on the passed in uri and xpath expression. But now xdmp:node-replace was giving error saying it cann't update external node. The other way of getting the old-element is by $docRoot/xdmp:value($xpath), but this gives me error: Prefix has no namespace binding, obviously there are 3-4 namespace prefix for the given xpath, not sure how to include those name-space bindings. xquery version "1.0-ml"; declare namespace xh = "http://www.w3.org/1999/xhtml"; declare namespace pam = "http://prismstandard.org/namespaces/pam/2.0/"; declare namespace prism = "http://prismstandard.org/namespaces/basic/2.1/"; declare namespace dc="http://purl.org/dc/elements/1.1/"; declare variable $tempURI := "/temp/a001.xml"; declare variable $xpath := "/pam:msg/pam:article/xh:head/dc:title"; declare variable $new-value := "Schools, some state agencies closed"; try { let $command := fn:concat(' declare namespace pam="http://prismstandard.org/namespaces/pam/2.0/"; declare namespace prism="http://prismstandard.org/namespaces/basic/2.1/"; declare namespace dc="http://purl.org/dc/elements/1.1/"; declare namespace xh="http://www.w3.org/1999/xhtml"; fn:doc("',$tempURI ,'")',$xpath) let $old-element := xdmp:eval($command) let $new-element := element {fn:node-name($old-element)} { $old-element/@*, $new-value} return xdmp:node-replace($old-element, $new-element) } catch($e){ xdmp:log($e),fn:concat("Problem editing the Temporary document node text : error: ",$e/error:message/text()) } Let me know if any one got any insights to this problem Thanks, Sugan
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
