XInclude Support

XInclude is a W3C standard for including XML snippets in XML files. You can use it to reduce duplication and improve the maintainability of your publication resources. Any element in a resource file that has an id attribute can be re-used other places in the same resource file by referencing it with an XInclude include element. The following field element, for example:

<field mime-type="text/plain" type="basic" name="title"  id="titleFields">
  <ui:label>Title</ui:label>
  <ui:description>The title of the article</ui:description>
  <constraints>
    <required>true</required>
  </constraints>
</field>

has the id titleFields, and can therefore be re-used in other places by simply entering:

<xi:include xpointer="titleFields"/>

In order to use XInclude in a resource file, you must declare its namespace. To declare the namespace in the root element of a content-type resource, for example, you would add the following (highlighted):

<content-types 
  xmlns="http://xmlns.escenic.com/2008/content-type" 
  xmlns:ui="http://xmlns.escenic.com/2008/interface-hints"
  xmlns:xi="http://www.w3.org/2001/XInclude"
  version="4">

Note the following restrictions:

  • Although XInclude supports inclusion between files, this is not supported in Escenic resource files. You can only include elements from the same file.

  • Only the following element types have id attributes in Escenic resource files:

    field
    relation-type

    These are therefore the only element types that can be re-used using XInclude.