From NGDC Wiki
Jump to: navigation, search

Replace Content with an Xlink to a Component

In this example I am replacing an entire section of the metadata with a reference to a component instead in more than 100 files at the same time.

See image right:
Find and replace in Multiple Files

You will need version 14.x of Oxgyen.

1. copy entire section that is being replaced.

      <gco:CharacterString>DEM text search tool</gco:CharacterString>
      <gco:CharacterString>Text search tool for locating completed and planned NOAA tsunami inundation DEMs.</gco:CharacterString>

2. replace all spaces or new lines with (\s+) to enable search across multiple lines. Check 'regular expression' in dialogue box.

<gmd:onlineResource>(\s+)<gmd:CI_OnlineResource>(\s+)<gmd:linkage>(\s+)<gmd:URL>http://www.ngdc.noaa.gov/dem/squareCellGrid/search</gmd:URL>(\s+)</gmd:linkage>(\s+)<gmd:name>(\s+)<gco:CharacterString>DEM text search tool</gco:CharacterString>(\s+)</gmd:name>(\s+)<gmd:description>(\s+)<gco:CharacterString>Text search tool for locating completed and planned NOAA tsunami inundation DEMs.</gco:CharacterString>(\s+)</gmd:description>(\s+)<gmd:function>(\s+)<gmd:CI_OnLineFunctionCode codeList="http://www.ngdc.noaa.gov/metadata/published/xsd/schema/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode" codeListValue="search">search</gmd:CI_OnLineFunctionCode>(\s+)</gmd:function>(\s+)</gmd:CI_OnlineResource>(\s+)</gmd:onlineResource>

3. replace with an xlink to the component

<gmd:onlineResource xlink:href=" https://ngdc.noaa.gov/docucomp/ec5e3f2b-4ed9-448f-b801-25d039f1922d" xlink:title="DEM Map Search"/>

Find and Replace Inconsistent Content

In this example, I am replacing the gmd:dateStamp/gco:Date value on 73 records. I only want to replace the gco:Date value for the metadata dateStamp (not any/all gco:Date tags) and the value is inconsistent across the records. To the right is a jpeg of the dialog box for editing multiple files in Oxygen.

Find and Replace with Regular Expression
  • Make sure your xml file is 'indented and formatted', so that each xml tag is on it's own line
  1. Select 'Find/Replace in Files' option in the 'Find' drop down menu
  2. copy/paste the xml tag your are replacing
    • e.g. <pubdate>19820101</pubdate>
    • replace the content with regular expression and check the 'regular expression' box, this enables you to find these tags with any content
    • e.g. <pubdate>.*</pubdate>
    • For more information: regular expressions in Perl
  3. type in XPath in 'Restrict to Xpath' field
    • e.g. metadata/idinfo/citation/citeinfo
    • note: DO NOT include the tags you are editing
    • you can get the xpath by right clicking on the desired tag in the editor and select 'Copy XPath' and then paste this into the field
  4. set replacement value in 'Replace With' field
    • e.g. <pubdate>2010-01-20</pubdate>
  5. select the 'Scope'
    • I usually run this on 'Project files', but you can also run this on a desktop directory
    • for testing I recommend run this first on one file ('selected project files')
  6. If this is not working you may need to reformat your XML


  • it's best to search w/o replacing first - to ensure that you don't override text you want to keep
  • there is also the option to make a backup copy
  • you can't undo the results
  • For most updates, a simple search and replace of text will suffice!
  • Tested on v11.1