【发布时间】:2018-01-03 23:38:07
【问题描述】:
我们需要将十六进制转换为二进制。经过很好的研究,我们能够实现它,但问题是输出在每组二进制元素之间都有空格。
如何去除这些空格?
以下代码给出的输出为: 0111 0110 0010 0100
必填: 0111011000100100
xquery version "1.0" encoding "utf-8"
(:: OracleAnnotationVersion "1.0" ::)
declare namespace ns1="http://www.s2mpos.com/v1";
(:: import schema at "s2miso8583.xsd" ::)
declare namespace bin="http://expath.org/spec/binary";
declare variable $ReadLine as xs:string external;
declare function local:charsReturn($arg as xs:string) as xs:string*
{
for $ch in string-to-codepoints($arg)
return codepoints-to-string($ch)
};
declare function local:convertString($argx as xs:string) as xs:string*
{
let $x := local:charsReturn($ReadLine)
for $a in $x
return
string-join(
for $b in (8,4,2,1)
let $cv := xs:integer($a)
let $xm := $cv mod ($b*2)
return
if ( $xm >= $b ) then "1" else "0"
,"")
};
declare function local:func($ReadLine as xs:string) as element() (:: schema-element(ns1:s2mMessages) ::) {
<ns1:s2mMessages>
{
let $abc := local:convertString($ReadLine)
}
</ns1:s2mMessages>
};
local:func($ReadLine)
【问题讨论】: