我如何使用 XQuery 将“aaa=1&bbb=2”之类的字符串转换为 xml
<request>
<aaa>1</aaa>
<bbb>2</bbb>
</request>
我尝试了以下代码,但失败了!
xquery version "1.0" encoding "GBK";
(:: pragma type="xs:anyType" ::)
declare namespace xf = "http://tempuri.org/BNetAP/Xquery/query2xml/";
declare function xf:query2xml($queryStr as xs:string)
as element(*) {
<query-params>
{
for $c in
fn:tokenize($queryStr, "&")
let $myname as xs:string := "{fn:substring-before($c,"=")}"
return
element
{fn:QName("", $myname)}
{"{fn:substring-after($c,"=")}"}
}
</query-params>
};
错误信息是:
line 15, column 6: "{http://www.w3.org/2004/07/xpath-functions}QName": unknown function (or number of arguments (2) is wrong) BNetAP/Xquery query2xml.xq line 15 1241431186406 397
我不知道为什么“QName”是一个“未知函数”?!