XSL Tranformation for Complex Attributes

yodaddy108

New Member
Im new to XSLT . I have an XML message as below :\[code\]<Root><Payload> <SendEmail> <customerID>123123</customerID> <subscriberID>123123</subscriberID> <MessageDetails> <AttributeList> <Attribute Name="CcEmailAddress">[email protected]</Attribute> <Attribute Name="BcccEmailAddress">[email protected]</Attribute> <Attribute Name="SenderEmailAddress">[email protected]</Attribute> <Attribute Name="SenderMobileNo">[email protected]</Attribute> <Content Name="MobileNo">[email protected]</Content> <Content Value="http://stackoverflow.com/questions/15490273/TxnNO">[email protected]</Content> <ERCo ercvalue="http://stackoverflow.com/questions/15490273/ERCNO">[email protected]</ERCo> <Attribute Name="OrderHeader"><![CDATA[" and ends with "]]></Attribute> </AttributeList> </MessageDetails> <MessageDetails> <AttributeList> <Attribute Name="CcEmailAddress">[email protected]</Attribute> <Attribute Name="BcccEmailAddress">[email protected]</Attribute> <Attribute Name="SenderEmailAddress">[email protected]</Attribute> <Attribute Name="SenderMobileNo">[email protected]</Attribute> <Content Name="MobileNo">[email protected]</Content> <Content Value="http://stackoverflow.com/questions/15490273/TxnNO">[email protected]</Content> <ERCo ercvalue="http://stackoverflow.com/questions/15490273/ERCNO">[email protected]</ERCo> <Attribute Name="OrderHeader"><![CDATA[" and ends with "]]></Attribute> </AttributeList> </MessageDetails> </SendEmail> </Payload></Root>\[/code\]Below are my requirements and questions :[*]In the AttributeList tag , i have to lookup for attribute "Name" which has a specific value (say CcEmailAddress ) and then map the corresponding Field Value (the actual email id) to my target tag . I tried //[@Name='CcEmailAddress'] As it appears once in my input , i decided to traverse through all the attributes with name as Name and value as CcEmailAddress . But it doesnt seem to be working .[*]How do i ensure that my code is selecting a specific occurance ? In my case Message details repeats n-times . If i use a select inside a for-each , it fetches only the first occuring value . When loop is on the second "MessageDetails" , i would want to get the values inside them . How do i achieve this ?[*]Inside AttributeList , i hold "Attribute" element and n-others . If i wanna search through the "Content" element and find a value where attribute "Name"=MobileNo (MobileNo can appear under any tag but i want only the thing under Content which repeats), how do i do it ?Thanks a lot for your help .
 
Back
Top