fonto-doc-load:resolve-content-reference-with-permanent-id

Type: Function

Resolve the reference with permantentIds 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-with-permanent-id ($conrefElement as element()) as map(*) {
    fonto-doc-load:resolve-content-reference-with-permanent-id(
        $conrefElement/@conref,
        function($resolvedTargetUrl as xs:string) as xs:string {
            if (fn:substring-before($resolvedTargetUrl, '#')) then
                fn:substring-before($resolvedTargetUrl, '#')
            else if (contains($resolvedTargetUrl, "#")) then
                fonto:remote-document-id($conrefElement)
            else
                $resolvedTargetUrl
        },
        function($doc as node(), $resolvedTargetUrl as xs:string) as element() {
            let $afterHash := fn:substring-after($resolvedTargetUrl, '#'),
                $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. url

    (Required)

    Type: String

    The permanent id that needs to be resolved. The result of the resolving is passed to the first callback

  2. extractRemoteDocumentId

    (Required)

    Type: Function

    Will be called with the result of resolving the permanent id, should return the remote document id part of the reference. The remote-document-id will be loaded and will be passed to the findTargetNode callback.

    Arguments

    Returns

  3. 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 both the document node of the loaded document and the result of resolving the permanent 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