Replace Xquery";替换给定索引的位掩码值;Oracle服务总线中的问题
我正在尝试替换32位字符串变量。首先,所有值均为“0” 我有一些索引值,应该用“1”替换这些索引中的值 例如,我有索引值=(3,10) 预期结果应为:Replace Xquery";替换给定索引的位掩码值;Oracle服务总线中的问题,replace,xquery,middleware,bitmask,osb,Replace,Xquery,Middleware,Bitmask,Osb,我正在尝试替换32位字符串变量。首先,所有值均为“0” 我有一些索引值,应该用“1”替换这些索引中的值 例如,我有索引值=(3,10) 预期结果应为: $bitmask:="00100000010000000000000000000000" 实际上我做到了:)但我的位掩码值中有空格字符。我无法删除空格字符 我的工作代码 $serviceBits := tokenize('0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
$bitmask:="00100000010000000000000000000000"
实际上我做到了:)但我的位掩码值中有空格字符。我无法删除空格字符
我的工作代码
$serviceBits := tokenize('0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0',',')
<services>
{
for $t at $pos in $serviceBits
let $temp := ''
return
if($pos = data($myElement/ns:position)) then
concat($temp, '1')
else
replace(concat($temp, $t)," ","")
}
</services>
$serviceBits:=标记化('0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0',','))
{
$t在$pos的$serviceBits中
让$temp:=''
返回
如果($pos=data($myElement/ns:position)),则
concat($temp,'1')
其他的
替换(concat($temp,$t),“”,“”)
}
我的工作代码的结果是
<services>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</services>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
代码中的问题是,在新构造的元素中发布了一个序列,该元素被序列化,中间带有空格。在此处显式使用字符串联接
:
<services>{
string-join(
(: all the other code for modification :),
'' (: Nothing between the individual strings :)
)
}</services>
<services>{
string-join(
(: all the other code for modification :),
'' (: Nothing between the individual strings :)
)
}</services>
let $bitmask := '00000000000000000000000000000000'
return
codepoints-to-string(
for $char at $i in string-to-codepoints($bitmask)
return
if ($i = (3,10))
then $char + 1
else $char
)