I found a javascript that allows Illustrator to write the contents of a variable to a specified NameSpace and Field. However, when it writes the XMP back to the file, it also clears the metadata in the dc:subject bag, which I don't want it to do. It is not clearing any of the metadata in any other Dublin Core fields or any of the fields of the specified namespace.

Any ideas why this behavior happens? I want a solution, but I want to understand the behavior more.

Thanks

Script Follows:

note: the variable "textContents" is defined in another part of the script not shown here.