XQuery 中 codepoints/integer 的问题
Problem with codepoints/integer in XQuery
所以我正在尝试执行这个简单的功能:
declare function local:decodeBase64() as element(){
<root-element>
{
let $codepointsString := "77 97 110"
let $codepoints := fn:replace( $codepointsString,' ',', ')
let $x := fn:codepoints-to-string(xs:integer($codepoints))
return
$x
}
</root-element>
};
但我收到一个错误,我认为这是因为 xs:integer
但是我可以用硬编码的整数执行这段代码
let $x := codepoints-to-string((77, 97, 110))
我注意到,如果我将 $codepoints 声明为 xs:integer*,我可以 运行 代码,但我不知道在元素中获取代码点并用作 xs:integer*调用代码点到字符串函数。
错误:
http://www.w3.org/2005/xqt-errors}FORG0001: "77 97 110": invalid value for cast/constructor: {http://www.w3.org/2001/XMLSchema}integer: error: decimal: Invalid decimal value: unexpected char '32'
原始字符串需要拆分为多个代码点字符串。然后可以将生成的字符串转换为整数:
let $codepointsString := "77 97 110"
let $codepoints := (
for $string in fn:tokenize($codepointsString, " ")
return xs:integer($string)
)
return fn:codepoints-to-string($codepoints)
所以我正在尝试执行这个简单的功能:
declare function local:decodeBase64() as element(){
<root-element>
{
let $codepointsString := "77 97 110"
let $codepoints := fn:replace( $codepointsString,' ',', ')
let $x := fn:codepoints-to-string(xs:integer($codepoints))
return
$x
}
</root-element>
};
但我收到一个错误,我认为这是因为 xs:integer
但是我可以用硬编码的整数执行这段代码
let $x := codepoints-to-string((77, 97, 110))
我注意到,如果我将 $codepoints 声明为 xs:integer*,我可以 运行 代码,但我不知道在元素中获取代码点并用作 xs:integer*调用代码点到字符串函数。
错误:
http://www.w3.org/2005/xqt-errors}FORG0001: "77 97 110": invalid value for cast/constructor: {http://www.w3.org/2001/XMLSchema}integer: error: decimal: Invalid decimal value: unexpected char '32'
原始字符串需要拆分为多个代码点字符串。然后可以将生成的字符串转换为整数:
let $codepointsString := "77 97 110"
let $codepoints := (
for $string in fn:tokenize($codepointsString, " ")
return xs:integer($string)
)
return fn:codepoints-to-string($codepoints)