This is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<CONTACTS>
<CONTACT>
<FirstName>Arun</FirstName>
<LastName>Arun_Neelam</LastName>
<Email>nuraaa_iceee@yahoo.co.in</Email>
</CONTACT>
<CONTACT>
<FirstName>Arun</FirstName>
<LastName>Arun_Neelam</LastName>
<Email>nuraaa_iceee@gmail.com</Email>
</CONTACT>
</CONTACTS>
1.How can i merge the above 2 contacts as single contact which is belongs to the same person
I would like to have an output like this:
<?xml version="1.0" encoding="windows-1250"?>
<CONTACTS>
<CONTACT>
<FirstName>Arun</FirstName>
<LastName>Arun_Neelam</LastName>
<Email>nuraaa_iceee@gmail.com</Email>
<Email>nuraaa_iceee@yahoo.co.in</Email>
</CONTACT>
</CONTACTS>
I'm not sure I can do it with current-group() and current-grouping-key()
.
Thank you very much for your support.
user639175, he helped for this problem and his solution is working but not giving my desired output. So i have changed the question in a simple way.
Note: I've formatted the question once again completely to avoid confusion in the same thread.
Using a standard grouping technique, you need just two templates (no loops, no params):
Your final transform:
In XSLT 2.0 you can use
xsl:for-each-group
; just replacewith:
I did not exclude Arun - because your exmaple has a flaw ? otherwise it works :)
It should work :)