fonto-doc-load:resolve-content-reference

Type: Function

Resolve the reference for configureAsInclusion and configureAsInclusionInFrame.

Other

module namespace dita = "http://www.fontoxml.com/functions/dita";

import module namespace fonto-doc-load = "http://www.fontoxml.com/functions/document-loading";
import module namespace fonto = "http://www.fontoxml.com/functions";

declare %public function dita:resolve-dita-conref ($conrefElement as element()) as map(*) {
    let $url := $conrefElement/@conref return
    fonto-doc-load:resolve-content-reference(
         if (fn:substring-before($url, '#')) then
            fn:substring-before($url, '#')
         else if (contains($url, "#")) then
            fonto:remote-document-id($conrefElement)
         else
            $url,
        function($doc as node()) as element() {
            let $afterHash := fn:substring-after($url, '#'),
                $target := if (contains($afterHash, "/")) then
                        $afterHash => fn:substring-after("/")
                    else
                        $afterHash
            return if ($target) then $doc/descendant-or-self::*[@id = $target] else $doc
        })
};

Arguments

  1. remoteDocumentId

    (Required)

    Type: String

    The remote id of the document in which the reference resides. Use the fonto:remote-document-id function on the 'current' node to resolve local references.

  2. findTargetNode

    (Required)

    Type: Function

    A callback that will be called to find the node(s) to which the reference points. This will be called with the document node that is related to the remote document id. Note that it is possible to return one or more target nodes if your inclusionr references more than one node.

    Arguments

    Returns

Returns

Type: Object

This function returns its state or intent, ie. load the document. This should be returned from the function configured in configureAsInclusion or configureAsInclusionInFrame