2015-05-20 6 views

ответ

1

попробуйте эту функцию.

functx:add-attributes(
    $in-xml/a, 
    (xdmp:node-insert-after('att1','att2')) or (xdmp:node-insert-before('att1','att2')),(1,2)). 
+0

Любые другие вместо использования функций? –

+0

Эта функция не обновляет существующий документ. –

+0

Я отредактировал мой код. –

0

Решил проблему с помощью следующего Xquery в MarkLogic.

(: create a document :) 
xdmp:document-insert("/example.xml", <a/>); 

(: insert an attribute as child of a :)  
xdmp:node-insert-child(doc("/example.xml")/a, 
attribute b { "bbb" }); 

(: look at the new document :) 
fn:doc("/example.xml") 

**Output** 

<?xml version="1.0" encoding="UTF-8"?> 
<a b="bbb"/> 

Источник: xdmp:node-insert-child

0

Использование обновления XQuery и Basex после будет решение -

for $x in doc('Document2')//a 
return 
insert node attribute att2{'2'} into $x 

Я надеюсь, что у вас уже есть ответ, по-прежнему ...

Смежные вопросы