Skip to content
Jesse Eichar edited this page Dec 10, 2013 · 7 revisions

Update a metadata record for the xpath/value provided. The xpath (in accordance with JDOM x-path) does not start with the root element for example:

Given the metadata:

 <gmd:MD_Metadata>
     <gmd:fileIdentifier></gmd:fileIdentifier>
  <gmd:MD_Metadata>

The xpath

gmd:MD_Metadata/gmd:fileIdentifier

will NOT select any elements. Instead one must use the xpath:

gmd:fileIdentifier

to select the gmd:fileIdentifier element.

To update the root element of the metadata use the xpath: "" (empty string)

The update value can be a String or an XML fragment. If the xpath matches an existing element, this element is updated. Only the first match is updated if more than one match.

If there are no matches, each missing nodes of the xpath are created and the element inserted according to the schema definition. If the XPath does not match an existing element and a new element is to be created, the xpath is restricted in what it can contain. Specifically they can not contain any condition blocks or any sibling or previous or ancestor declarations. SOme forbidden elements are:

  • ..
  • //
  • ancestor::

If the end of the xpath is an attribute:

elem/@att

the attribute (att) of the element (elem) will be set instead of the text of the element.

Note: if an attribute is to be updated then the new value must be a string and not xml.

The rules for updating an element with Xml is as follows:

  • If the xml's root element is the same as the element selected by the XPATH then node is replaced with the element. For example: Xpath: gmd:fileIdentifier XML: <gmd:fileIdentifier gco:nilReason='withheld'> Result: the gmd:fileIdentifier element in the metadata will be completely replaced with the new one. All attributes in the metadata will be lost and replaced with the attributes in the new element.

  • If the xml's root element == 'gn_replace' (a magic tag) then the children of that element will be replace the element selected from the metadata.

  • If the xml's root element == 'gn_add' (a magic tag) then the children of that element will be added to the element selected from the metadata.

  • If the xml's root element != the name (and namespace) of the element selected from the metadata then the xml will replace the children of the element selected from the metadata.

Clone this wiki locally