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

Type: Function

Resolve the reference with permantentIds for configureAsInclusion and configureAsInclusionInFrame.

Arguments

# Name Type Description
1. url String

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

2. extractRemoteDocumentId 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
# Name Type Description
1. string
  Returns

Type: String

3. findTargetNode 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
# Name Type Description
1. Node
2. string
  Returns

Type: Array<Node>

Example

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
        })
};

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

Was this page helpful?