Metadata Elements

This section explains how to process metadata elements using the KeyView API.

Standardized Elements

When KeyView understands the meaning of a metadata field in a document, it outputs that data in a standardized element - a MetadataElement object where:

  • is_standard() returns true.
  • standard_key() returns the standard key, which indicates the meaning of the element. For a list of standard keys, refer to the MetadataKey enumeration in the file Keyview_Metadata.hpp, or see Standardized Metadata Elements. The standard key will not be equal to MetadataKey::Other.

  • key() returns a string that is uniquely determined by the standard key. If you are handling the value of a standardized element based on its standard key, you can ignore this value. It is provided so that standardized elements can optionally be handled in the same way as non-standardized elements.

  • has_standard_alternative() returns false.
  • is_superseded() specifies whether this element has been superseded, meaning that this element exists only to preserve backwards compatibility. An element can be superseded to fix issues with the key or value type. When this method returns true, the same metadata is available through an improved MetadataElement in the same Metadata object.

Each standardized element is guaranteed to occur at most once in the metadata output. For example, a Metadata object will contain zero or one MetadataElement objects with the standard key Title. To get a specific standard element from a Metadata object, pass the standard key to the at() member function.

Non-standardized Elements

Non-standard elements represent native metadata fields. Some non-standard elements might have been used to create a standardized element, and therefore have a standardized alternative. User-created metadata fields, and fields that are unique to one file format, are usually available only as non-standard elements. For a non-standard metadata element:

  • is_standard() returns false.
  • standard_key() returns MetadataKey::Other.
  • key() returns a string representation of a field's key. If a field key exists in the document, that value is returned. Otherwise, KeyView generates a value.
  • has_standard_alternative() specifies whether the element has a standardized alternative. When this method returns true, this element contains metadata that also exists in a standardized MetadataElement in the same Metadata object. The standardized element might present the metadata with different units.
  • is_superseded() specifies whether this element has been superseded, meaning that this element exists only to preserve backwards compatibility. An element can be superseded to fix issues with the key or value type. When this method returns true, the same metadata is available through an improved MetadataElement in the same Metadata object.

Field Values

OpenText recommends that you process metadata field values as appropriate types through a visitor pattern. To do this, write a class that inherits from the MetadataVisitorBase class and handles each of the possible metadata types. Then, pass your class to the apply_visitor() method of a MetadataElement object.

You can also obtain a field value as a string by calling the method convert_to_string() on a MetadataElement object.