我目前正在为我的应用编制索引。在学习了教程之后,我走到了尽头:
err:FORG0001 can not convert '/.../collection.xconf' to xs:integer [at line 65, column 26]
我有点知道问题出在哪里,但是我还没有找到解决方案。我认为我需要从我的函数中排除collection.xconf:
declare function app:test($node as node(), $model as map(*)) {
for $doc in collection(concat($config:app-root, "/data/edition"))
let $id := replace(document-uri($doc),".*/([^.]*)\.xml", "$1") cast as xs:integer
order by $id
return
<li class="semanticClassNameFinden" data-target="#carouselIndicators" data-slide-to="{$id - 29}" style="list-style:none;"> Page {$id}v/ {$id+1}r </li>
};
如何从功能中排除此文件?
我曾考虑过在[for-line]中添加?select=*.xml
之类的内容或添加'*.xml'
,但这样做只会在未运行的函数中返回。还有其他提示吗?
最良好的祝愿,K
collection.xconf
函数返回的结果中排除诸如collection()
之类的文件,您可以断言该函数可以过滤掉不需要的命名空间中的节点。例如,比较以下两个查询:查询1
xquery version "3.1";
collection("/db/apps/eXide")
此查询应返回两个文档:一个带有<package>
根元素(来自expath-pkg.xml
),另一个带有<collection>
根元素(来自collection.xconf
文件)。查询2
declare namespace cc="http://exist-db.org/collection-config/1.0";
collection("/db/apps/eXide")[not(cc:collection)]
此查询仅返回一个文档:带有<package>
根元素的文档(来自expath-pkg.xml
)。它滤出了collection.xconf
文件。