我正在尝试从集合(文件系统)生成树视图。不幸的是,某些文件具有特殊字符,例如 ü ä 和 ö。我想让它们 html 编码为ä
当我从变量中获取它们时,它们是 URL 编码的。首先我将它们解码为 UTF-8,然后....我不知道如何更进一步。
<li><a href="#">{util:unescape-uri($child, "UTF-8")}</a>
该功能util:parse
与我想要的完全相反。
这是递归函数:
xquery version "3.0";
declare namespace ls="ls";
declare option exist:serialize "method=html media-type=text/html omit-xml-declaration=yes indent=yes";
declare function ls:ls($collection as xs:string, $subPath as xs:string) as element()* {
if (xmldb:collection-available($collection)) then
(
for $child in xmldb:get-child-collections($collection)
let $path := concat($collection, '/', $child)
let $sPath := concat($subPath, '/', $child)
order by $child
return
<li><a href="#">{util:unescape-uri($child, "UTF-8")}</a>
<ul>
{ls:ls($path,$sPath)}
</ul>
</li>,
for $child in xmldb:get-child-resources($collection)
let $sPath := concat($subPath, '/', $child)
order by $child
return
<li> <a href="javascript:loadPage('{$sPath}');">{util:unescape-uri($child, "UTF-8")}</a></li>
)
else ()
};
let $collection := request:get-parameter('coll', '/db/apps/ebner-online/resources/xss/xml')
return
<ul>{ls:ls($collection,"")}</ul>