努力使以下工作:我正在尝试合并翻译的节点,但由于有时节点集之间存在细微差异,我不能这样做,只是蒙上眼睛,需要手动审查。然而,与此同时,我喜欢让我的生活保持简单,所以我想尽可能多地实现自动化。举个例子:
<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)
谢谢 !