以下を機能させるのに少し苦労しています:翻訳されたノードをマージしようとしていますが、ノードセット間にわずかな違いがある場合があるため、目隠しをしてこれを行うことはできず、手動で確認する必要があります。しかし同時に、私は自分の人生をシンプルに保つのが好きなので、可能な限り前もって自動化したいと思っています。以下の例を見てください:
<root>
<chapter>
<string class="l1"><local xml:lang="en">Some English here</local></string>
<string class="p"><local xml:lang="en">Some other English here</local></string>
<string class="p"><local xml:lang="en">and some English here</local></string>
<string class="p"><local xml:lang="en">Some English here</local></string>
</chapter>
<chapter>
<string class="l1"><local xml:lang="fr">Some English translated to French here</local></string>
<string class="p"><local xml:lang="fr">Some other English translated to French here</local></string>
<string class="p"><local xml:lang="fr">and some English translated to French here</local></string>
<string class="p"><local xml:lang="fr">Some English translated to French here</local></string>
</chapter>
<chapter>
<string class="l1"><local xml:lang="de">Some English translated to German here</local></string>
<string class="p"><local xml:lang="de">Some other English translated to German here</local></string>
<string class="another_class"><local xml:lang="de">and some English translated to German here</local></string>
<string class="p"><local xml:lang="de">Some English translated to German here</local></string>
</chapter>
<chapter>
<string class="l1"><local xml:lang="nl">Some English translated to Dutch here</local></string>
<string class="p"><local xml:lang="nl">Some other English translated to Dutch here</local></string>
<string class="p"><local xml:lang="nl">and some English translated to Dutch here<br/>Some English translated to Dutch here</local></string>
</chapter>
</root>
実際のファイルには30の言語と数百のノードを含めることができるため、上記の例は非常に単純化されています。
この例で達成したいのは、英語とフランス語をマージすることです。これらは両方とも同じ量の要素を持ち、すべての属性も同じだからです。すべての属性が一致するわけではないため、フランス語はそのままにする必要があります。要素の量が一致しないため、オランダ語はそのままにする必要があります。
したがって、出力は次のようになります。
<root>
<!-- French has the same amount of elements, and a full sequential match of attributes, so we can merge -->
<chapter>
<string class="l1">
<local xml:lang="en">Some English here</local>
<local xml:lang="fr">Some English translated to French here</local>
</string>
<string class="p">
<local xml:lang="en">Some other English here</local>
<local xml:lang="fr">Some other English translated to French here</local>
</string>
<string class="p">
<local xml:lang="en">and some English here</local>
<local xml:lang="fr">and some English translated to French here</local>
</string>
<string class="p">
<local xml:lang="en">Some English here</local>
<local xml:lang="fr">Some English translated to French here</local>
</string>
</chapter>
<!-- German has same amount of elements, but different tag sequence, so we leave it for manual review -->
<chapter>
<string class="l1"><local xml:lang="de">Some English translated to German here</local></string>
<string class="p"><local xml:lang="de">Some other English translated to German here</local></string>
<string class="another_class"><local xml:lang="de">and some English translated to German here</local></string>
<string class="p"><local xml:lang="de">Some English translated to German here</local></string>
</chapter>
<!-- Dutch has same same tag sequence but less elements, so we leave it for manual review-->
<chapter>
<string class="l1"><local xml:lang="nl">Some English translated to Dutch here</local></string>
<string class="p"><local xml:lang="nl">Some other English translated to Dutch here</local></string>
<string class="p"><local xml:lang="nl">and some English translated to Dutch here<br/>Some English translated to Dutch here</local></string>
</chapter>
</root>
英語は常にマスターリファレンスであるため、英語のノード数を比較として使用することで、サイズの異なるノードセットをすでに除外できます。すべての属性値が等しいかどうかを確認する方法がわかりません。
何かアドバイス ?(xslt2を使用)
ありがとう !