If you want to update @language ='en' only, you can try this,
xdmp:node-replace(/catalog/product/name[@language = 'en']/@language,
attribute language {"chinese"})
On Wed, Jul 1, 2015 at 7:16 PM, Dave Cassel <[email protected]>
wrote:
> To Asit's point, if you need to make an update like this across a large
> number of documents, take a look at Corb2
> <https://github.com/marklogic/corb2>.
>
> --
> Dave Cassel <http://davidcassel.net>, @dmcassel
> <https://twitter.com/dmcassel>
> Technical Community Manager
> MarkLogic Corporation <http://www.marklogic.com/>
> http://developer.marklogic.com/
>
>
> From: Indrajeet Verma <[email protected]>
> Reply-To: MarkLogic Developer Discussion <[email protected]>
> Date: Wednesday, July 1, 2015 at 1:21 AM
> To: MarkLogic Developer Discussion <[email protected]>
> Subject: Re: [MarkLogic Dev General] how to update the attribute of nodes?
>
> Hi Zise,
>
> You can try below code as well,
>
> xdmp:node-replace(/catalog/product/name/@language, attribute language
> {"chinese"})
>
> Regards,
> Indy
>
> On Wed, Jul 1, 2015 at 10:37 AM, Asit Nautiyal <[email protected]>
> wrote:
>
>> Hi Zise,
>>
>> There are various ways to do this simple task. Find the below sample
>> code :
>>
>> let $doc := fn:doc("/xmlFile.xml")
>> let $oldNode := $doc/catalog/product/name[@language="en"]
>> let $newNode := element {fn:local-name($oldNode)} { attribute language {"
>> chinese"}, $oldNode/text()}
>>
>> return xdmp:node-replace($oldNode,$newNode)
>>
>> Above code will work as expected. But, if your database size is very
>> huge and you want to perform such update on entire database then use
>> cts:queries for better performance.
>>
>>
>> Regards,
>> Asit Nautiyal
>>
>> ------------------------------
>> Date: Wed, 1 Jul 2015 11:50:02 +0800
>> From: [email protected]
>> To: [email protected]
>> Subject: [MarkLogic Dev General] how to update the attribute of nodes?
>>
>>
>> the xml document is:
>> <catalog>
>> <productdept="ACC">
>> <number>
>> 443
>> </number>
>> <namelanguage="en">
>> Deluxe Travel Bag
>> </name>
>> </product>
>> </catalog>
>>
>> I want to update the attirbute language of node name to new value,
>> after update operation, the name node is:
>> <namelanguage="chinese">
>> Deluxe Travel Bag
>> </name>
>>
>> which function can do this in marklogic 8.0?
>>
>>
>>
>> _______________________________________________ General mailing list
>> [email protected] Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general