About metadata schema modules

Last updated on
30 April 2025

A metadata schema module should implement the following hooks:

hook_xc_schema

It gives an abstract metadata schema, which is converted to MySQL tables and processing rules. The automatic conversion is processed by the XC Metadata module.

The schema should have the following structure:

entity
  title
  description
  fields
    'field name' with the following properties: name, namespace, title, 
         description, required, size, max_size, default_value, possible_values
     attributes
       'attribute name' with the following properties: name, namespace, title, 
         description, required, size, max_size, default_value, possible_values
  namespaces
    'prefix' with the following descriptions: uri, title, description

The schema will be preserved as a row of MySQL table records by the Metadata module's xc_install_schema function.

The entities became XCMetadataEntity objects (MySQL: xc_metadata_entity).

The fields became XCMetadataField objects (MySQL: xc_metadata_field).

The attributes became XCMetadataAttribute objects (MySQL: xc_metadata_attribute).

The namespaces became XCMetadataNamespace objects (MySQL: xc_metadata_namespace).

Above the listed fields every object has a module attribute. The set_definition() method saves the objects into MySQL records.

hook_xc_build

Construct objects from a schema in raw XML format.

  • Parsing the raw input for entity instances
  • Constructing XCEntity objects
  • Calling hook_build_xc() (recursively) for each object
hook_xc_transform(&$object, $format, $params = array())

Convert each XCEntity objects metadata into XC schema in XML format. Returns
an array of XML strings.
Parameters:

$object
Array of XCEntity objects
$format
For export, must equal 'xc:xml'
$params
Additional arguments
hook_xc_format

Gives information about the implemented formats. The hook should return an array of formats. Each format should give information about the following:

name
The name of the format
description
Format description
entities (array)
Array of entity names inside the format
module
The module implements this schema
help
Additional information (help message).
download (boolean)
Is downloadable?
upload (boolean)
Can be uploaded?
file extension
Default file extension of the format (like 'xml')
content type
The MIME content type (like 'text/xml')
namespaceURI
The namespace URI of the root element (like 'http://www.openarchives.org/OAI/2.0/oai_dc')
schemaLocation
The schemaLocations of the referenced namespaces
root element
The XML's root element (like 'oai_dc:dc')

Getting information about schema inside a module - API functions

Getting information about the format

xc_format_get($format_name)

It gives you an array with the following keys:

name
the name of the schema
description
description of the schema
entities
an array of entities name inside the schema
module
the module which defines this schema
help message
download
(boolean) is it possible to download schema record?
upload
(boolean) is it possible to upload schema record?
file extension
the usual file extension (e.g. 'xml')
content type
the mime type of the schema
namespaceURI
the namespace URI of the schema
schemaLocation
the location of XML schemas used inside
root element
the root element's qualified name

Help improve this page

Page status: Not set

You can: