Input File:
<?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>
Note: I have to use 1.0 version of XSLT.
If you are truly limited to XSLT 1.0, you will have to do this in three steps:
Tokenize the
chat
values. Ideally, at the end of this step you would have a variable containing:Convert the variable into a node-set, using the EXSLT
exsl:node-set()
function (or another similar function supported by your processor).Group the items by the
chat
attribute, using Muenchian grouping.There are plenty of examples here showing how to do each step. If you run into problems, post a specific question.
Note that some XSLT processors support some extension functions that could be helpful here - notably:
str:tokenize()
andset:distinct()
.