xquery - 用于嵌套和连接的 Xquery
问题描述
这是我修改后的输入 XML:
<Input>
<BIKey></BIKey>
<BusinessObjects>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
<BusinessAttributes>
<BusinessAttribute>
<BKey>Version</BKey>
<BValue>1</BValue>
</BusinessAttribute>
<BusinessAttribute>
<BKey>date</BKey>
<BValue>2018-06-28</BValue>
</BusinessAttribute>
</BusinessAttributes>
</BusinessObject>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
<BusinessAttributes>
<BusinessAttribute>
<BKey>Version</BKey>
<BValue>1</BValue>
</BusinessAttribute>
<BusinessAttribute>
<BKey>date</BKey>
<BValue>2018-06-28</BValue>
</BusinessAttribute>
</BusinessAttributes>
</BusinessObject>
</BusinessObjects>
</Input>
我想将以下输出CDC|123|857895:CDC|123|34567
分配给<BIKey>
.
我试过这个 Xquery:
<Input>
<BIKey>{ string-join(data($Input/BusinessIdentifiers/BusinessIdentifier/BValue),'|') }</BIKey>
</Input>
但我得到了这个输出CDC|123|857895|CDC|123|34567
。
我怎样才能解决这个问题?
解决方案
您使用了错误的功能,使用string-join(sequence, '|')
,而不是concat
例如
<Input>
<BIKey>{ string-join(Input/BusinessIdentifiers/BusinessIdentifier/BValue, '|') }</BIKey>
</Input>
推荐阅读
- html - 如何在表 td 中添加闪烁的文本光标(插入光标)
- python - 看门狗脚本只能检测自己直接创建的文件(而不是目标软件)
- codemirror - 用 CodeMirror 输入 KeyPress 上的 HTML 节点替换已知关键字
- webapi - JSON 响应中的异常处理
- python - Pyspark 爆炸列表创建列与列表中的索引
- swiftui - 如何使用 foreach 在 SwiftUI 中基于测试数据创建多个单元格预览
- jdbc - SAP DBTech JDBC:[305]:单行查询返回多于一行
- jenkins - 未指定凭据从远程 Git 获取更改
- typescript - 如何创建一个响应原生的打字稿项目?
- amazon-web-services - Json 数组到 Athena/Presto 中的表列