Depending on the distinct value of "type" in the following xml I need to generate a sequence number and add that to the resulting xml.
For. If there are two distinct "type" elements then
"sequence number" should be 1 for the first one
and 2 for the second type.
<Sample>
<num>5700</num>
<MAIN>
<type>1101</type>
<SUB>
<text>aaa</text>
</SUB>
</MAIN>
<MAIN>
<type>1102</type>
<SUB>
<text>bbbb</text>
</SUB>
</MAIN>
<MAIN>
<trans_type>1101</trans_type>
<SUB>
<text>cccc</text>
</SUB>
</MAIN>
</Sample>
Result should be as follows:
<Sample>
<num>5700</num>
<MAIN>
<type>1101</type>
<sequencenum>1</<sequencenum>
<SUB>
<text>aaa</text>
</SUB>
</MAIN>
<MAIN>
<type>1102</type>
<sequencenum>2</<sequencenum>
<SUB>
<text>bbbb</text>
</SUB>
</MAIN>
<MAIN>
<trans_type>1101</trans_type>
<sequencenum>1</<sequencenum>
<SUB>
<text>cccc</text>
</SUB>
</MAIN>
</Sample>
Please let me know how to get the result in xslt.
I tried using count and number but did not got the answer.
Any help is highly appreciated.
Regards,
agsp
For. If there are two distinct "type" elements then
"sequence number" should be 1 for the first one
and 2 for the second type.
<Sample>
<num>5700</num>
<MAIN>
<type>1101</type>
<SUB>
<text>aaa</text>
</SUB>
</MAIN>
<MAIN>
<type>1102</type>
<SUB>
<text>bbbb</text>
</SUB>
</MAIN>
<MAIN>
<trans_type>1101</trans_type>
<SUB>
<text>cccc</text>
</SUB>
</MAIN>
</Sample>
Result should be as follows:
<Sample>
<num>5700</num>
<MAIN>
<type>1101</type>
<sequencenum>1</<sequencenum>
<SUB>
<text>aaa</text>
</SUB>
</MAIN>
<MAIN>
<type>1102</type>
<sequencenum>2</<sequencenum>
<SUB>
<text>bbbb</text>
</SUB>
</MAIN>
<MAIN>
<trans_type>1101</trans_type>
<sequencenum>1</<sequencenum>
<SUB>
<text>cccc</text>
</SUB>
</MAIN>
</Sample>
Please let me know how to get the result in xslt.
I tried using count and number but did not got the answer.
Any help is highly appreciated.
Regards,
agsp