Xquery для Гнезда и Конкат - PullRequest
0 голосов
/ 13 сентября 2018

Вот мой измененный входной 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.

Как я могу это исправить?

1 Ответ

0 голосов
/ 13 сентября 2018

Вы использовали неправильную функцию, используйте string-join(sequence, '|'), а не concat, например,

<Input>    
    <BIKey>{ string-join(Input/BusinessIdentifiers/BusinessIdentifier/BValue, '|') }</BIKey>
</Input>

https://xqueryfiddle.liberty -development.net / 948Fn5e

...