Configure inclusions

This guide describes how to configure inclusion. Examples of inclusions are the XML inclusions spec and the conref attribute in dita. Because the conref attribute is supported by default in the Fonto Editor, this guide will focus on the XML inclusions (XInclude) specification.

In most XML tooling, XInclude is regarded as a pre-processing step. During the parsing of a document, all XInclude elements are resolved and replaced with what they reference. However when editing the XML with the Fonto Editor, the inclusions should be present in the document so that you can work with them. Therefore, at least in the schema specific for the Fonto Editor, the XInclude is required to be in the schema for the places where content can be referenced.

This guide uses examples where custom functions are declared in the db namespace "". Refer to the guide on namespaces for to learn how to choose a namespace for the editor.


Configure the xi:include element as an inclusion

In a configureSxModule, add the following declaration:


configureAsInclusion(sxModule, 'self::xi:include[@href]', 'include', 
		functionName: 'resolve-xinclude',
		namespaceUri: ''

Define the referenced function

In an XQuery module file, add the following import and the following function declaration:


module namespace db = "";
import module namespace fonto-doc-load = "";

declare %public function db:resolve-xinclude ($inclusion as element()) as map(*) {
    let $url := $inclusion/@href return
        function($doc) {$doc/*/*})

For more information on XQuery modules refer to the documentation.

The result of an inclusion of an element.

A screenshot of external content included in the Editor