使用xquery

时间:2018-01-03 12:14:14

标签: xml xquery

我们要求将十六进制转换为二进制。经过深入研究,我们能够实现它,但问题是输出在每组二进制元素之间有空格。

如何删除这些空格?

下面的代码给出了输出:     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)

1 个答案:

答案 0 :(得分:1)

我看不出你的代码是如何工作的。如果from __future__ import absolute_import, unicode_literals # This will make sure the app is always imported when # Django starts so that shared_task will use this app. from .celery import app as celery_app __all__ = ['celery_app'] 包含十六进制数字,那么$ a可以是任何十六进制数字,例如“C”,如果web: gunicorn project.wsgi --log-file - worker: celery worker --app=tasks.app 是“C”,则$Readline将因FORG0001而失败。

我愿意:

$a