Skip to content

Import facilities

Importing a metadata record from XML or a MEF file

The file import facility allows you to import metadata records in three ways:

  1. XML file from the filesystem on your machine.
  2. MEF file from the filesystem on your machine
  3. Copy/Paste XML

In order to use this facility, you have to be logged in as an editor. After the login step, go to the administration page and select the Metadata insert link.

Clicking the link will open the metadata import page. You will then have to specify a set of parameters. The following screenshot shows the parameters for importing an XML file.

figure The XML file import options

We'll describe the options you see on this page because they are common ways you can import metadata records in this interface.

  • File Type - First option is to choose the type of metadata record you are loading. The two choices are:

    • Metadata - use when loading a normal metadata record
    • Template - use when loading a metadata record that will be used as a template to build new records in the editor.
  • Import Action - This option group determines how to handle potential clashes between the UUID of the metadata record you are loading and the UUIDs of metadata records already present in the catalog. There are three actions and you can select one:

    • No action on import - the UUID of the metadata record you are loading is left unchanged. If a metadata record with the same UUID is already present in the catalog, you will receive an error message.
    • Overwrite metadata with same UUID - any existing metadata record in the catalog with the same UUID as the record you are loading will be replaced with the metadata record you are loading.
    • Generate UUID for inserted metadata - create new a UUID for the metadata records you are loading.
  • Stylesheet - Allows you to transform the metadata record using an XSLT stylesheet before loading the record. The drop down control is filled with the names of files taken from the INSTALL_DIR/web/geonetwork/xsl/conversion/import folder. (Files can be added to this folder without restarting GeoNetwork). As an example, you could use this option to convert a metadata into schema that is supported by GeoNetwork.

  • Validate - The metadata is validated against its schema before loading. If it is not valid it will not be loaded.
  • Group - Use this option to select a user group to assign to the imported metadata.
  • Category - Use this option to select a local category to assign to the imported metadata. Categories are local to the catalogue you are using and are intended to provide a simple way of searching groups of metadata records.

MEF file import

figure The MEF file import options

If you select MEF file in the File type option, only the Import actions option group is show. See above for more details. Note: a MEF file can contain more than one metadata record.

Copy/Paste XML

figure The XML insert options

If you select Copy/Paste in the Insert mode option, then a text box appears. You can copy the XML from another window and paste it into that text box. The options for loading that XML are the same as those for loading an XML file - see above.

Batch import

The batch import facility allows you to import a set of metadata records in the form of XML or MEF files. In order to use this facility, you have to be logged in as an administrator. After the login step, go to the administration page and select the Batch Import link.

figure How to reach the batch import page

Clicking the link will open the batch import page. You will then have to specify a set of parameters. The following screenshot shows the parameters for batch import of a set of XML or MEF files.

figure The batch import options

  • Directory This is the full path on the server's file system of the directory to scan. GeoNetwork will look for and try to import all XML or MEF files present into this directory. It is important to notice that this is the directory on the server machine and not on the client of the user that is doing the import.
  • File Type - First option is to choose the type of metadata record you are loading. The two choices are:

    • Metadata - use when loading a normal metadata record
    • Template - use when loading a metadata record that will be used as a template to build new records in the editor.
  • Import Action - This option group determines how to handle potential clashes between the UUID of the metadata record you are loading and the UUIDs of metadata records already present in the catalog. There are three actions and you can select one:

    • No action on import - the UUID of the metadata record you are loading is left unchanged. If a metadata record with the same UUID is already present in the catalog, you will receive an error message.
    • Overwrite metadata with same UUID - any existing metadata record in the catalog with the same UUID as the record you are loading will be replaced with the metadata record you are loading.
    • Generate UUID for inserted metadata - create new a UUID for the metadata records you are loading.
  • Stylesheet - Allows you to transform the metadata record using an XSLT stylesheet before loading the record. The drop down control is filled with the names of files taken from the INSTALL_DIR/web/geonetwork/xsl/conversion/import folder. (Files can be added to this folder without restarting GeoNetwork). As an example, you could use this option to convert a metadata into schema that is supported by GeoNetwork.

  • Validate - The metadata is validated against its schema before loading. If it is not valid it will not be loaded.
  • Group - Use this option to select a user group to assign to the imported metadata.
  • Category - Use this option to select a local category to assign to the imported metadata. Categories are local to the catalogue you are using and are intended to provide a simple way of searching groups of metadata records.

At the bottom of the page there are two buttons:

  • Back Goes back to the administration form.
  • Upload Starts the import process.

Notes on the batch import process

  • When the import process ends, the total count of imported metadata will be shown
  • The import is transactional: the metadata set will be fully imported or fully discarded (there are no partial imports)
  • Files that start with '.' or that do not end with '.xml' or '.mef' are ignored

Structured batch import using import-config.xml

Finer control of the batch import process can be obtained by structuring the metadata files into directories mapped to categories and metadata schemas and describing the mapping in a file called import-config.xml.

The import-config.xml should be placed in the directory from which you will batch import (see Directory parameter above). It has a config root element with the following children:

  1. categoryMapping [1]: this element specifies the mapping of directories to categories.
    1. mapping [0..n]: This element can appear 0 or more times and maps one directory name to a category name. It must have a "dir" attribute that indicates the directory and a "to" attribute that indicates the category name.
    2. default [1]: This element specifies a default mapping of categories for all directories that do not match the other mapping elements. The default element can only have one attribute called "to".
  2. schemaMapping [1]: this element specifies the mapping of directories to metadata schemas.
    1. mapping [0..n]: This element can appear 0 or more times and maps one directory to the schema name that must be used when importing. The provided schema must match the one used by the metadata contained into the specified directory, which must all have the same schema. It must have a "dir" attribute that indicates the directory and a "to" attribute that indicates the schema name.
    2. default [1]: default behaviour to use when all other mapping elements do not match. The default element can only have one attribute called "to".

Here is an example of the import-config.xml file:

<config>
    <categoryMapping>
        <mapping dir="1" to="maps" />
        <mapping dir="3" to="datasets" />
        <mapping dir="6" to="interactiveResources" />
        <mapping dir="30" to="photo" />
        <default to="maps" />
    </categoryMapping>
    <schemaMapping>
        <mapping dir="3" to="fgdc-std" />
        <default to="dublin-core" />
    </schemaMapping>
</config>

As described above, the import procedure starts by scanning the specified Directory. Apart from the import-config.xml file, this directory should only contain subdirectories - these are the category directories referred to in the categoryMapping section of the import-config.xml file described above. Each of the category directories should only contain subdirectories - these are the schema directories referred to in the schemaMapping section of the import-config.xml file described above.