Среда: eXist-db 4.2.1, XQuery 3.1
Я построил в eXist числовые функции, которые самостоятельно выводят результаты HTML как функции (когда я передаю параметры напрямую).Например, эта маленькая функция (document:doc-sidebar-sub4
in /modules/document.xql
):
module namespace document="/db/apps/fooapp/modules/document";
declare namespace templates="http://exist-db.org/xquery/templates";
import module namespace common="/db/apps/fooapp/modules/common" at "/db/apps/fooapp/modules/common.xql";
declare function document:doc-sidebar-sub4(
$node as node(),
$model as map(*),
$currentdoc as xs:string)
{
let $sidebar :=
(<div class="sidebar-sub-4">
<p><span class="en">To cite this document:</span></p>
<p>{common:cite-doc($currentdoc,"html")}</p>
</div>)
return $sidebar
};
Создает небольшой фрагмент HTML-кода, полученный из документа foo-doc_0099.xml
(путем вызова другой функции):
<div class="sidebar-sub-4">
<p><span class="en">To cite this document:</span></p>
<p><span>Joe Smith. <i>Digital Edition of some old manuscript</i>.
http://www.foosite.fr/foo-doc_0099.xml. Retrieved 2018-10-14.</span>
</p>
</div>
Я сейчас пытаюсь включить этот фрагмент в свой основной document.html
(с документом, жестко закодированным в параметре - в конечном итоге, получить из HTTP-запроса) с этим div
:
<div data-template="templates:include"
data-template-with="document:doc-sidebar-sub4"
data-template-currentdoc="foo-doc_0099.xml"/>
Но выдает следующую ошибку:
exerr:ERROR XPTY0004: The actual cardinality for parameter 3 does not match the cardinality declared in the function's signature: templates:include($node as node(), $model as map, $path as xs:string) item()*. Expected cardinality: exactly one, got 0. [at line 219, column 14, source: /Users/foo/Library/Application Support/org.exist/expathrepo/shared-0.4.2/content/templates.xql]
Другая версия этого же шаблона вызывает другую ошибку:
<div data-template="templates:include"
data-template-with="document:doc-sidebar-sub4"
data-template-path="modules/document.xql"
data-template-currentdoc="foo-doc_0099.xml"/>
Ошибка:
err:FODC0005 exerr:ERROR Document /db/apps/fooapp/modules/document.xql is a binary resource, not an XML document. Please consider using the function util:binary-doc() to retrieve a reference to it. [at line 436, column 27, source: /Users/foou/Library/Application Support/org.exist/expathrepo/shared-0.4.2/content/templates.xql]
Я пытался следовать демонстрациям, различным учебным пособиям и ответам, включая this , но не могу определить проблему.
Другая версия, другая ошибка.Этот звонок
<div data-template="document:doc-sidebar-sub4" data-template-path="modules/document.xql":>
Производит:
templates:NotFound No template function found for call document:doc-sidebar-sub4 [at line 189, column 85, source: /Users/foo/Library/Application Support/org.exist/expathrepo/shared-0.4.2/content/templates.xql]
Заранее большое спасибо за любую помощь для этого ученика.
Редактировать: добавлены корректировки из@joewiz, другие ошибки возвращаются