ISSUE: We want to be able to batch update all values in our ISO 19139 XML metadata files that reside in the GeoNetwork editing application. We have a python script (CSW-Update) that can import a spreadsheet of values to make batch changes to the metadata files.
CHALLENGE: Our CSW-Update script cannot (yet) create certain elements that are not nested or contain special attributes.
SOLUTION: Use XML Refactoring in Oxygen to create blank elements. Re-upload the metadata files to GeoNetwork, and then the CSW-Update script works.
Steps:
1. Download the metadata files from GeoNetwork and unzip them.
2. Open one file in Oxygen and go to Tools-XML Refactoring
3. Select Insert Element
4. The fields are not well documented in the Oxygen application, however, so below the image, I have indicated what they mean.
Local Name: This is the text that will be inside the tag. You cannot specify a prefix here.
Namespace: You have to type in the full URI of the namespace.
You must also declare the namespace in another window. Click the text at the bottom of the popup window Default prefix-namespace mappings. Click NEW and add the prefix on the left column and the namespace URI on the right column. This prefix will be prepended to the Local Name in the output.
XPath: this is the XPath of an element that is already present in the XML document. In the example below, it is the element that will contain the Local Name. The prefix should be included here.
Position: You can choose from Before, After, First Child, and Last Child. You may want to experiment to figure out the best way to place the new element. There is a preview button on the next screen to let you test the results before committing them.
5. Click Next and choose which files to change.
6. Click Preview to see if the element will be inserted correctly.
7. Click Finish.
8. Re-upload to GeoNetwork with the Overwrite feature and proceed with updating the empty elements.
Note: To do this in a batch, open all the files in Oxygen or create a Project.