这是我修改的输入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>