Access Metadata Fields

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

Standardized Fields

When KeyView understands the meaning of a metadata field in a document, it outputs that data in a standardized field. Standardized fields are represented as MetadataElement objects where:

  • is_standard() returns true.

  • standard_key() returns the standardized field key, which indicates the meaning of the field. For a full list of standardized keys, refer to the MetadataKey enumeration in the file Keyview_Metadata.hpp. The returned standard key will not be equal to MetadataKey::Other.

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

Each standardized field 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 field from a Metadata object, pass the standard key to the at() member function.

Non-standardized fields

Non-standardized fields include user created fields, or fields that are specific to that type of document. KeyView handles these in the following way:

  • is_standard() returns false.
  • standard_key() returns MetadataKey::Other to signify that it is a non-standardized field.
  • 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 to describe the field.

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.