如何使用 @corresp 属性创建的显式交叉引用对 XML 源中元素 <seg> 的值进行分组?
<DIV>
<div id="fr">
<seg id="fr_1" corresp="#en_1">abc</seg>
<seg id="fr_2" corresp="#en_2 #en3">def</seg>
<seg id="fr_3" corresp="#en_3 #en_4">ghi</seg>
<seg id="fr_4" corresp="#en_4 #en_5">jkl</seg>
<seg id="fr_5" corresp="#en_6">mno</seg>
</div>
<div id="en">
<seg id="en_1" corresp="#fr_1">ab</seg>
<seg id="en_2" corresp="#fr_1 #fr_2">cde</seg>
<seg id="en_3" corresp="#fr_2 #fr_3">fg</seg>
<seg id="en_4" corresp="#fr_3 #fr_4">hij</seg>
<seg id="en_5" corresp="#fr_4">kl</seg>
<seg id="en_6" corresp="#fr_5">mno</seg>
</div>
</DIV>
XSLT 转换后的输出应如下所示:
<div>
<ul>
<li>abc<br/>ab</li>
<li>abc<br/>cde</li>
<li>def<br/>cde</li>
<li>def<br/>fg</li>
<li>ghi<br/>fg</li>
<li>ghi<br/>hij</li>
<li>jkl<br/>hij</li>
<li>jkl<br/>kl</li>
<li>mno<br/>mno</li>
</ul>
</div>
谢谢!
@Jirka,这是一个类似的输入,但在元素中嵌套了更多元素。而corresp 属性定义了这些新元素之间的交叉引用。修改后的输入如下所示:
<DIV>
<div id="fr">
<seg id="fr_1"><w id="fr1" corresp="#en2">AA</w> <w id="fr2" corresp="#en3">BB</w>, <w id="fr3" corresp="#en1">CC</w>.</seg>
<seg id="fr_2"><w id="fr1" corresp="#en1">DD</w> <w id="fr2" corresp="#en3">EE</w>?</seg>
<seg id="fr_3"><w id="fr1" corresp="#en1">FF</w> <w id="fr2" corresp="#en3">GG</w><w id="fr3" corresp="#en2">HH</w></seg>
</div>
<div id="en">
<seg id="en_1"><w id="en1" corresp="#fr3">AX</w><w id="en2" corresp="#fr1">BX</w><w id="en3" corresp="#fr2">CX</w></seg>
<seg id="en_2"><w id="en1" corresp="#fr1">DX</w><w id="en2" corresp="#en0">EX</w><w id="en3" corresp="#en2">FX</w></seg>
<seg id="en_3"><w id="en1" corresp="#fr1">HX</w> <w id="en2" corresp="#en3">IX</w><w id="en3" corresp="#en2">JX</w>.</seg>
</div>
所需的输出应如下所示:
<div>
<ol>
<li><w>AA</w> : <w>BX</w><br/><w>BB</w> : <w>AX</w><br/> </li>
<li><w>DD</w> : <w>DX</w><w>EE</w> : <w>FX</w><br/><br/> </li>
<li><w>FF</w> :<w>HX</w><br/> <w>GG</w> :<w>JX</w><br/><w>HH</w>:<w>IX</w><br/></li>
</ol>
</div>