For my setup I have an external program that saves an xmp packet (not rdf) to a file. Using a script in Ilustrator I then read that packet and append it to the active documents existing xmp using XMPFile and XMPUtils. The updated xmp is then saved to the active document using XMPFile and putXmp.
You should be able to skip the external xmp file part and use the setProperty() method directly on a copy of the active documents xmp and then save that back to the .ai file.
Here's a simplified (and working) example as it's easier to explain with code:
// Load the XMP Script library
if( xmpLib == undefined ) {
var xmpLib = new ExternalObject("lib:../../Frameworks/AdobeXMPScript");
app.synchronousMode = true;
}
//Create an XMPMeta object from the active documents XMPString:
var docXmp = new XMPMeta(app.activeDocument.XMPString);
//Make a copy that we can work with:
var myXmp = docXmp;
//Make our changes:
myXmp.setProperty(XMPConst.NS_XMP, "CreatorTool", "My Script");
//Append the modified xmp to the original xmp object:
XMPUtils.appendProperties(myXmp, docXmp, XMPConst.APPEND_REPLACE_OLD_VALUES);
//Create a File object of the active document so we can use .fsName (XMPFile seems to be picky):
var myDocFile = new File(app.activeDocument.fullName);
//Open the active document for writing:
var docRef = new XMPFile(myDocFile.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
//Check that we can write the xmp before writing it
if (docRef.canPutXMP(docXmp)) { docRef.putXMP(docXmp); }
//Save the active document (user will have to re-open file to see updated xmp in file info panel)
docRef.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
Most of what I've learned about the xmp library came from the following pdf so if you haven't already you should check it out:
http://www.adobe.com/devnet/scripting/estk/pdfs/javascript_tools_guide_cs3.pdf
HTH.