Add namespace into XMP metadata

Is it possible and how to add some data in XMP Metadata? For example I want to save this two values (employee name and version) to XMP. I try something with AI but not successfully :grinning: This is draft of my react component . Thanks in advance

import React, { useState } from 'react';
const { core } = require('photoshop');
const uxp = require('uxp');

const Info = () => {
  const [retoucher, setRetoucher] = useState('');
  const [version, setVersion] = useState('');

  const handleSave = async () => {
    const XMP = uxp.storage.XMP;

    try {
      const app = require('photoshop').app;
      const activeDocument = app.activeDocument;

      const xmp = await XMP.fromDocument(activeDocument);
      const namespace = "http://testPlugin.com/ns/";

      xmp.setProperty(namespace, "retoucher", retoucher);
      xmp.setProperty(namespace, "version", version);

      await xmp.applyToDocument(activeDocument);

      console.log('XMP metadata successfully saved.');
      alert('XMP metadata successfully updated!');

    } catch (error) {
      console.error('Error saving XMP metadata:', error);
      alert('An error occurred while saving XMP metadata: ' + error.message);
    }
  };

  return (
    <>
      <sp-heading>INFO</sp-heading>
          <div>
            <label>Retoucher: </label>
            <input
              type="text"
              value={retoucher}
              onChange={(e) => setRetoucher(e.target.value)}
            />
          </div>
          <div>
            <label>Version: </label>
            <input
              type="text"
              value={version}
              onChange={(e) => setVersion(e.target.value)}
            />
      </div>

      <div className="confirmBtns">
        <sp-button onClick={handleSave} size="m" quiet variant="accent">Run</sp-button>
      </div>
    </>
  );
};

export default Info;

Hello,

I don’t work with Photoshop, but the procedure will be similar for XMP. I think the namespace has to be registered first and then the properties can be added. Example for a container:

var _ns = "http://testPlugin.com/ns/";

XMPMeta.registerNamespace(_ns, "testPlugin:");

  var _xmpData = _xmpFile.getXMP();

  _xmpData.setProperty(_ns, "testPluginArray", "", XMPConst.PROP_IS_ARRAY);
  _xmpData.appendArrayItem(_ns, "testPluginArray", null, XMPConst.PROP_IS_STRUCT);
  _xmpData.setStructField(_ns, "testPluginArray[1]", XMPConst.NS_RDF, "retoucher", "Name of the Retoucher");
  _xmpData.setStructField(_ns, "testPluginArray[2]", XMPConst.NS_RDF, "version", "0.0.0");

Roland