制作从一个元素到另一个元素的聊天表 [英] Make chat sheet from one element to another element
问题描述
输入文件:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<a>
<notice>100</notice>
<chat>10, 20, 30, 40</chat>
</a>
<a>
<notice>101</notice>
<chat>40, 50, 60</chat>
</a>
<a>
<notice>102</notice>
<chat>10, 30, 60</chat>
</a>
<a>
<notice>103</notice>
<chat>70, 10, 20</chat>
</a>
</root>
我的要求是创建一个聊天条目并找到如下示例所示的受影响通知:
My requirement is make a chat entry and find the effected notice like below example:
<a>
<chat>10</chat>
<notice>100, 102, 103</notice>
</a>
<a>
<chat>20</chat>
<notice>100, 103</notice>
</a>
<a>
<chat>30</chat>
<notice>100, 102</notice>
</a>
注意:我必须使用 1.0 版本的 XSLT.
推荐答案
如果您确实仅限于 XSLT 1.0,则必须分三步完成:
If you are truly limited to XSLT 1.0, you will have to do this in three steps:
标记
chat
值.理想情况下,在此步骤结束时,您将有一个包含以下内容的变量:
Tokenize the
chat
values. Ideally, at the end of this step you would have a variable containing:
<item notice="100" chat="10"/>
<item notice="100" chat="20"/>
<item notice="100" chat="30"/>
<item notice="100" chat="40"/>
<item notice="101" chat="40"/>
<item notice="101" chat="50"/>
<item notice="101" chat="60"/>
<item notice="102" chat="10"/>
<item notice="102" chat="30"/>
<item notice="102" chat="60"/>
<item notice="103" chat="70"/>
<item notice="103" chat="10"/>
<item notice="103" chat="20"/>
使用 EXSLT 节点集rel="nofollow noreferrer">exsl:node-set()
函数(或其他类似的函数支持您的处理器).
Convert the variable into a node-set, using the EXSLT exsl:node-set()
function (or another similar function supported by
your processor).
按chat
属性将项目分组,使用慕尼黑分组.
这里有大量示例展示了如何执行每个步骤.如果遇到问题,请发布特定问题.
There are plenty of examples here showing how to do each step. If you run into problems, post a specific question.
请注意,一些 XSLT 处理器支持一些可能对这里有用的扩展函数 - 特别是:str:tokenize()
和 set:distinct()
.
Note that some XSLT processors support some extension functions that could be helpful here - notably: str:tokenize()
and set:distinct()
.
这篇关于制作从一个元素到另一个元素的聊天表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!