【发布时间】:2018-09-14 08:05:46
【问题描述】:
这是我的输入 XML:
这是我修改后的 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>
我已经按照 Martin 的建议尝试了这个 Xquery,它实际上解决了我之前的问题,但与我之前的问题相比,我的 inputpayload 更多:
<Input>
For $BusinessObject in Input/BusinessObjects/BusinessObject[1]
retrun
<BIKey>{ string-join(Input/BusinessObjects/BusinessObject[1]/BusinessIdentifiers/BusinessIdentifier/BValue, '|') }</BIKey>
</Input>
但我得到了这个输出
CDC|123|857895
请协助解决这个问题,因为我不确定在哪里循环有效负载以获得所需的输出。
谢谢
【问题讨论】:
标签: xquery