Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello there,
Need Help...
I am converting source xml to target xml using xslt . I have below two questions :
<ns0:SID>4567</ns0:SID>
<urn:sessionId />
Below are the source XML, XSLT Transform and Target XML
Source XML :
<?xml version="1.0" encoding="UTF-8"?> <ns0:Submit_Input xmlns:ns0="http://soap.sforce.com/schemas/class/test"> <ns0:ListOfInboundResponse> <ns0:TransactionHeader> <ns0:ListOfTransactionDetailItems> <ns0:ErrorDesc>123</ns0:ErrorDesc> <ns0:ErrorNum /> <ns0:ErrorSeverity /> <ns0:LineNumber /> <ns0:Status /> </ns0:ListOfTransactionDetailItems> <ns0:PONumber /> <ns0:SID>4567</ns0:SID> <ns0:TransactionId /> <ns0:TransactionMode /> <ns0:TransactionNumber /> <ns0:TransactionRowId /> <ns0:TransactionStatus /> <ns0:TransactionType /> </ns0:TransactionHeader> <ns0:TransactionHeader> <ns0:ListOfTransactionDetailItems> <ns0:ErrorDesc /> <ns0:ErrorNum /> <ns0:ErrorSeverity /> <ns0:LineNumber /> <ns0:Status /> </ns0:ListOfTransactionDetailItems> <ns0:PONumber /> <ns0:TransactionId /> <ns0:TransactionMode /> <ns0:TransactionNumber /> <ns0:TransactionRowId /> <ns0:TransactionStatus /> <ns0:TransactionType /> </ns0:TransactionHeader> </ns0:ListOfInboundResponse> </ns0:Submit_Input>
XSLT Transform
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com"> <soapenv:Header> <urn:SessionHeader> <urn:sessionId> <xsl:value-of select="SID" /> </urn:sessionId> </urn:SessionHeader> </soapenv:Header> <soapenv:Body> <xsl:copy-of select="." /> </soapenv:Body> </soapenv:Envelope> </xsl:template> </xsl:stylesheet>
Target XML
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com"> <soapenv:Header> <urn:SessionHeader> <urn:sessionId /> </urn:SessionHeader> </soapenv:Header> <soapenv:Body> <ns0:Submit_Input xmlns:ns0="http://soap.sforce.com/schemas/class/test"> <ns0:ListOfInboundResponse> <ns0:TransactionHeader> <ns0:ListOfTransactionDetailItems> <ns0:ErrorDesc>123</ns0:ErrorDesc> <ns0:ErrorNum /> <ns0:ErrorSeverity /> <ns0:LineNumber /> <ns0:Status /> </ns0:ListOfTransactionDetailItems> <ns0:PONumber /> <ns0:SID>4567</ns0:SID> <ns0:TransactionId /> <ns0:TransactionMode /> <ns0:TransactionNumber /> <ns0:TransactionRowId /> <ns0:TransactionStatus /> <ns0:TransactionType /> </ns0:TransactionHeader> <ns0:TransactionHeader> <ns0:ListOfTransactionDetailItems> <ns0:ErrorDesc /> <ns0:ErrorNum /> <ns0:ErrorSeverity /> <ns0:LineNumber /> <ns0:Status /> </ns0:ListOfTransactionDetailItems> <ns0:PONumber /> <ns0:TransactionId /> <ns0:TransactionMode /> <ns0:TransactionNumber /> <ns0:TransactionRowId /> <ns0:TransactionStatus /> <ns0:TransactionType /> </ns0:TransactionHeader> </ns0:ListOfInboundResponse> </ns0:Submit_Input> </soapenv:Body> </soapenv:Envelope>
Thanks Kiran
(Edited to display the code snippets)
Hi Kiran,
(Note: I've edited the question to show the code snippets, which were hidden - hope that's alright with everyone)
Here's a transform XSLT that does the trick - it looks a bit scary because of the namespaces, when in reality, it's pretty straightforward, e.g.:
EDIT: Looks like code snippets are broken again, sigh...
I've posted a Gist with the code here
Hope that helps,
/Chriztian
Thank you Chriztian. That works !!!!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
XML Transformation using XSLT -get value-of select and to delete a element
Hello there,
Need Help...
I am converting source xml to target xml using xslt . I have below two questions :
<ns0:SID>4567</ns0:SID>
from source XML to Target XML element<urn:sessionId />
using XSLT<ns0:SID>4567</ns0:SID>
when source XML transforms to Target XMLBelow are the source XML, XSLT Transform and Target XML
Source XML :
XSLT Transform
Target XML
Thanks Kiran
(Edited to display the code snippets)
Hi Kiran,
(Note: I've edited the question to show the code snippets, which were hidden - hope that's alright with everyone)
Here's a transform XSLT that does the trick - it looks a bit scary because of the namespaces, when in reality, it's pretty straightforward, e.g.:
EDIT: Looks like code snippets are broken again, sigh...
I've posted a Gist with the code here
Hope that helps,
/Chriztian
Thank you Chriztian. That works !!!!
is working on a reply...