Hello ,
I have a requirement to convert an xml document to another xml document using xslt. I am new to xml and xslt and need your help in solving this problem.
I have a xml file which looks like below
<Vendor>
<contact Id="1234" CmpnyNm="ABC" ContactNm="Sheryl">
<Phone Number="555-5555" Type="WorkPhone"/>
</Contact>
<contact Id="1234" CmpnyNm="ABC" ContactNm="Sheryl">
<Phone Number="666-6666" Type="WorkPhone"/>
</Contact>
<contact Id="1234" CmpnyNm="ABC" ContactNm="Sheryl">
<Phone Number="999-9999" Type="WorkPhone"/>
</Contact>
</Vendor>
Since the attributes in the contact element, Id,CmpnyNm and ContactNm are same for the three recs and only the phone number is different, I want to have the 3 phone numbers under one contact element itself.
Please see below how I need to have the output xml.
<vendor>
<contact Id="1234" cmpnyNm="ABC" ContactNm="Sheryl">
<Phone Number="555-5555" Type="WorkPhone"/>
<Phone Number="666-6666" Type="WorkPhone"/>
<Phone Number="999-9999" Type="WorkPhone"/>
</Contact>
</Vendor>
Is it possible to have the output in this format?. I tried xslt but looks like it needs complex logic in the xslt to achieve the output, but unfortunately I am not good at xml and xslt.
Any help in solving this problem would be greatly appreciated.
Thank you
Manoj