XML Metadata Transformation

medialoopster can import external metadata along with media files by using sidecar XML files in watchfolders. Additionally, medialoopster provides an XSLT mapping to transform an external XML schema to medialoopster's own XML schemas. There are different target schema definitions for video, audio and image assets.

Prerequisites

In order to import XML metadata you need to prepare some things:

  • Define source and target schemas based on the XML namespace URIs of your schemas.
  • Create an XSL stylesheet to define the metadata mapping.
  • Make sure that you define a XSLT_ROOT path variable in your environment file. If it is not defined, medialoopster uses /mnt/medialoopster/xslt/ as default.
  • Set up the XML transformation with the source schema, target schema and XSLT file in the medialoopster administration interface.

XML schemas

medialoopster administration → XMLTRANSFORM → XML schemas

Definition of XML schemas.

Options

NameRequiredDescription
NameNoName of the XML schema.
Namespace URIYesUniform Resource Identifier of the XML schema.

XML transformations

medialoopster administration → XMLTRANSFORM → XML transformations

An XML transformation consists of the source and target XML schemas as well as the XSLT stylesheet file. All three have to be set up first in the medialoopster administration.

Options

NameRequiredDescription
Source schemaYesSource schema.
Target schemaYesTarget schema, usually one of medialoopster's own schemas for video, audio and image assets.
XSLT fileYesXSLT stylesheet file.
ActiveNo

Whether the transformation should be applied when importing an XML metadata file. An inactive transformation does not have any effect.

XSLT files

medialoopster administration → XMLTRANSFORM → XSLT files

A XSLT stylesheet file can be uploaded here. The destination path of the uploaded file is defined by the XSLT_ROOT path variable in your environment file. After the stylesheet is uploaded once, it can be changed directly at its destination location.

Options

NameRequiredDescription
FileYes

XSLT stylesheet file.

Stylesheet Parameters

When transforming a metadata XML file to the medialoopster import schema, the current state of the asset can be accessed using the stylesheet parameter asset, which refers to the root element of a document matching the export schema for video, audio or image assets.

Example Transformation

The following example stylesheet transforms an XML document of a fictional schema "http://example.com/xyzmeta" to the medialoopster videoasset import schema.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xyz="http://example.com/xyzmeta"
    xmlns:ex="http://medialoopster.com/export/videoasset">
    <xsl:param name="asset" />
    <xsl:template match="/xyz:xyzmeta">
        <videoasset xmlns="http://medialoopster.com/import/videoasset">
            <name><xsl:value-of select="xyz:title"/></name>
            <meta_field_store>
                <field name="source"><xsl:value-of select="xyz:source" /></field>
                <field name="author"><xsl:value-of select="xyz:author" /></field>
            </meta_field_store>
            <sequences>
                <sequence>
                    <shots>
                        <shot>
                            <duration><xsl:value-of select="$asset/ex:duration" /></duration>
                            <location_city><xsl:value-of select="xyz:location" /></location_city>
                        </shot>
                    </shots>
                </sequence>
            </sequences>
        </videoasset>
    </xsl:template>
</xsl:stylesheet>

Asset document:

<videoasset xmlns="http://medialoopster.com/export/videoasset">
    [...]
    <duration>1234</duration>
    <sequences>
        <sequence>
            <timecode_start>0</timecode_start>
            <timecode_end>1233</timecode_end>
            <duration>1234</duration>
            [...]
            <shots>
                <shot>
                    <timecode_start>0</timecode_start>
                    <timecode_end>999</timecode_end>
                    <duration>1000</duration>
                    <location_city>HH</location_city>
                    [...]
                </shot>
                <shot>
                    <timecode_start>1000</timecode_start>
                    <timecode_end>1233</timecode_end>
                    <duration>234</duration>
                    <location_city>HB</location_city>
                    [...]
                </shot>
            </shots>
        </sequence>
    </sequences>
</videoasset>

Input document:

<xyzmeta xmlns="http://example.com/xyzmeta">
    <title>XYZ</title>
    <author>Alice Johnson</author>
    <source>ABC</source>
    <location>HH</location>
</xyzmeta>

Resulting output document:

<videoasset xmlns="http://medialoopster.com/import/videoasset">
    <name>XYZ</name>
    <meta_field_store>
        <field name="author">Alice Johnson</field>
        <field name="source">ABC</field>
    </meta_field_store>
    <sequences>
        <sequence>
            <shots>
                <shot>
                    <duration>1234</duration>
                    <location_city>HH</location_city>
                </shot>
            </shots>
        </sequence>
    </sequences>
</videoasset>

Effects when importing this metadata document:

  • A single sequence with a single shot is created with the duration of the asset and the location defined in the input document.
  • The existing sequences of the video asset are completely replaced with the sequences defined in the import document.
  • If the sequences tag had been omitted, existing sequences would have been preserved.
  • The source and author tags from the input document are written as custom metadata.
  • Existing custom metadata will be preserved.

Name Version Published
audioasset-export.xsd 2 2018-10-12 09:14
audioasset-import.xsd 2 2018-03-09 16:21
imageasset-export.xsd 2 2018-10-12 09:14
imageasset-import.xsd 2 2018-03-09 16:21
videoasset-export.xsd 2 2018-10-12 09:14
videoasset-import.xsd 2 2018-03-09 16:22