dmasd
dmasd

Reputation: 13

How do I prevent xdmp:node-delete() from adding whitespace in my xml doc

I am trying to MOVE a node from one xml document to another. Both documents are using the same namespace. I am trying to accomplish this by doing xdmp:node-insert-child() on the first document then xdmp:node-delete() on the second document in a sequence. The problem is that the xdmp:node-delete() is leaving spaces and returns in my xml doc. How can I keep this from happening?

Here is a code example...

let $documentId := 12345
let $newStatus := 123
let $processNode := $PROCESS-DOC//pex:process[(@documentId = $documentId)]    
let $newNode :=
       element { QName($TNS, 'process') } {
        attribute status { $newStatus },
        attribute documentId { $processNode/@documentId },
       }  
return
    if ($processNode and $newNode) then
      (xdmp:node-insert-child($PROCESS-COMPLETE-DOC/pex:processes, $newNode),xdmp:node-delete($processNode))
    else ()

Upvotes: 1

Views: 272

Answers (1)

mblakele
mblakele

Reputation: 7842

It sounds like the whitespace is held in text nodes on either side of the node you are deleting. You could verify this by inspecting xdmp:describe($processNode/preceding-sibling::text()) and xdmp:describe($processNode/following-sibling::text()). And if you like, you could xdmp:node-delete some or all of those text nodes too.

Upvotes: 1

Related Questions