Given the following XML as input,
<?xml version="1.0" encoding="UTF-8"?>
<TABLE NAME="TABLE.DB">
<DATA RECORDS="2">
<RECORD ID="4">
<RECNO>0</RECNO>
<SEQ>0</SEQ>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10354</NUMBER>
<CN>PL</CN>
<PROPERTY>0</PROPERTY>
<DAYS>0</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
<TOTALS>1</TOTALS>
</RECORD>
<RECORD ID="3">
<RECNO>1</RECNO>
<SEQ>0</SEQ>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10355</NUMBER>
<CN>PL</CN>
<PROPERTY>0</PROPERTY>
<DAYS>0</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
<TOTALS>1</TOTALS>
</RECORD>
<RECORD ID="2">
<RECNO>2</RECNO>
<SEQUENCE>0</SEQUENCE>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10356</NUMBER>
<CN>PL 300 L</CN>
<PROPERTY>0</PROPERTY>
<DAYS>10</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
<SUB_A>Some random data not matched.</SUB_A>
</RECORD>
<RECORD ID="1">
<RECNO>3</RECNO>
<SEQUENCE>0</SEQUENCE>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10357</NUMBER>
<CN>PL 300 L</CN>
<PROPERTY>0</PROPERTY>
<DAYS>10</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
<TOTALS>19837</TOTALS>
</RECORD>
<RECORD ID="0">
<RECNO>3</RECNO>
<SEQUENCE>0</SEQUENCE>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10358</NUMBER>
<CN>PL 300 L</CN>
<PROPERTY>0</PROPERTY>
<DAYS>10</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
</RECORD>
</DATA>
</TABLE>
and the following tab separated file:
[yet another value.]\t10358
value i'd like to add\t10355
(another) value i'd like to add\t10357
i used \t, in order to show where the tab exists in the file. i would like to append the data found in the first column, into the element i try to match on, which in this case in NUMBER.
So if NUMBER equals second column, append to it the value found in the first column, using | as a separator.
how one could have the below result, but with keeping the order of the records, sorting on the element Output:
<?xml version="1.0" encoding="UTF-8"?>
<TABLE NAME="TABLE.DB">
<DATA RECORDS="2">
<RECORD ID="0">
<RECNO>3</RECNO>
<SEQUENCE>0</SEQUENCE>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10358 | [yet another value.]</NUMBER>
<CN>PL 300 L</CN>
<PROPERTY>0</PROPERTY>
<DAYS>10</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
</RECORD>
<RECORD ID="1">
<RECNO>3</RECNO>
<SEQUENCE>0</SEQUENCE>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10357 | (another) value i'd like to add</NUMBER>
<CN>PL 300 L</CN>
<PROPERTY>0</PROPERTY>
<DAYS>10</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
<TOTALS>19837</TOTALS>
</RECORD>
<RECORD ID="2">
<RECNO>2</RECNO>
<SEQUENCE>0</SEQUENCE>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10356</NUMBER>
<CN>PL 300 L</CN>
<PROPERTY>0</PROPERTY>
<DAYS>10</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
<SUB_A>Some random data not matched.</SUB_A>
</RECORD>
<RECORD ID="3">
<RECNO>1</RECNO>
<SEQ>0</SEQ>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10355 | value i'd like to add</NUMBER>
<CN>PL</CN>
<PROPERTY>0</PROPERTY>
<DAYS>0</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
<TOTALS>1</TOTALS>
</RECORD>
<RECORD ID="4">
<RECNO>0</RECNO>
<SEQ>0</SEQ>
<DATE>17/12/1999 2:44:08 μμ</DATE>
<ID>12/11/2015 3:15:25 μμ</ID>
<NUMBER>10354</NUMBER>
<CN>PL</CN>
<PROPERTY>0</PROPERTY>
<DAYS>0</DAYS>
<CURRENTSTATUS>0</CURRENTSTATUS>
<TOTALS>1</TOTALS>
</RECORD>
</DATA>
</TABLE>
I use Saxon latest, v 9.8
The
xsl:merge
is similar to your previous question and to sort the merge result you can simply wrap thexsl:merge
into anxsl:perform-sort
: