0
我試圖從一個集合(文件系統)中生成一個樹形視圖。不幸的是,一些文件具有特殊字符,如üä和ö。我希望他們的HTML編碼爲ä
在eXist-db/XQuery中將字符串編碼爲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>