But I have other problem with subtract value B and P for each event. Source code is for example like this:
<EVENTS>
<ROW ID="204" ID_PLACE="1" EVENT_TYPE="B" EVENT_NAME="TEST1" EVENT_ID="201">
<PRICE>
<ROW EVENT_PRICE="165,00"/>
</PRICE>
</ROW>
<ROW ID="205" ID_PLACE="1" EVENT_TYPE="P" EVENT_NAME="TEST1" EVENT_ID="201">
<PRICE>
<ROW EVENT_PRICE="125,00"/>
</PRICE>
</ROW>
<ROW ID="206" ID_PLACE="1" EVENT_TYPE="B" EVENT_NAME="TEST2" EVENT_ID="202">
<PRICE>
<ROW EVENT_PRICE="100,00"/>
</PRICE>
</ROW>
<ROW ID="207" ID_PLACE="1" EVENT_TYPE="P" EVENT_NAME="TEST2" EVENT_ID="202">
<PRICE>
<ROW EVENT_PRICE="135,00"/>
</PRICE>
</ROW>
</EVENTS>
and I have to get something like that:
<EVENT_ID>201</EVENT_ID>
<DIFF>40.00</DIFF>
<EVENT_ID>202</EVENT_ID>
<DIFF>-35.00</DIFF>
etc. In this case I now what EVENT_ID is in file, but not always it is only this two ID so I can't do this like this: for ID=201 diff is 40, for 202 diff is -35. How to write xsl transform for every ID_EVENT which is in the source code.
Another way is to use grouping:
XSLT 2.0
In my answer to your previous question, I remarked that there are other ways to approach the problem of matching corresponding
<ROW>
elements than looking for those with a common<EVENTS>
parent. The situation presented in this question requires such an approach.One might do that with keys or with XSLT 2.0 grouping, as other answers suggest. But another way would be simply to write a suitable XPath expression to select the 'P' row matching each 'B' row (or vise versa). For example,
I would use a key to link the rows by their
EVENT_ID
:XSLT 1.0
Demo: http://xsltransform.net/bEzjRJW