Fork me on GitHub

Defining a media linked to image document type

Media attribute types

There are three media attribute types:

  • user filled : this kind of attribute is filled by user at link insertion. It is not associated with a document attibute.

  • text document provided : this kind of attribute is automatically filled with the text value of a document attribute. It can be modified by the user during link selection.

  • binary document provided : this kind of attribute is automatically filled with the url of a binary resource. It cannot be modified.

Media attributes

For this media, we define four attributes:

  • src : defines the url to the content

  • alt : the alternatives text if the content cannot be found

  • height : the image height

  • width : the image width

Those attributes are used to create the HTML representation of this media. This representation depends on the XSL Stylesheet provided with the media. Here is a sample stylesheet for our media :

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="media">
        <img src="{src}" alt="{alt}" height="{height}" width="{width}"/>
</xsl:template>

</xsl:stylesheet>

Notice that the variables {src}, {alt}, {height} and {width} match the media attribute codes.

Mapping definition

Now we have to create one or more mappings that associate our four attributes with image document type attributes. This is done by adding a new mapping and associating media attribute with document type attributes.