次のような xml 行セットが定義されています。
<root>
<dataset1>
<rows>
<row id="0" title="Some Title" lookupValues="1;#Something1;#2;#Something2"/>
<row id="1" title="Some other title" lookupValues="1;#Something1;#3;#Something3"/>
</rows>
</dataset1>
<dataset2>
<rows>
<row id="1" lookupValue="Something1" anotherValue="ThisOne"/>
<row id="2" lookupValue="Something2" anotherValue="ThatOne"/>
<row id="3" lookupValue="Something3" anotherValue="TheOtherOne"/>
<row id="4" lookupValue="Not Something"/>
</rows>
</dataset2>
</root>
そして、次のような形式に変換しようとしています:
<newroot>
<rows>
<row uniqueid="1" id="0" title="Some Title" lookupValue="Something1" anotherValue="ThisOne"/>
<row uniqueid="2" id="0" title="Some Title" lookupValue="Something2" anotherValue="ThatOne"/>
<row uniqueid="3" id="1" title="Some other title" lookupValue="Something1" anotherValue="ThisOne"/>
<row uniqueid="4" id="1" title="Some other title" lookupValue="Something3" anotherValue="TheOtherOne"/>
</rows>
</newroot>
重複する行に注意してください。これはアプリの要件です。また、欠落した lookupValue 行が削除されていることにも注意してください。
この変換を実現する本当に効率的な方法を知っている人はいますか?
ありがとう。
更新: 何を達成しようとしているのかをもっと明確にするべきでした。探しているマージのタイプをよりよく説明するために、いくつかの情報を追加しました。
更新 2:元のデータセットにエラーがあったことを除いて、与えられた答えはうまくいった可能性があります。つまり、lookupValues
属性の形式です。ソース XML には実際のルックアップ テキストに加えてインデックス番号が含まれているため、区切り文字は少し異なります。