Jump to content

XML Transformation using XSTL -get value-of select


Kiran_w3

Recommended Posts

Hello there,

 

Need Help...in XSTL coding

 

I am converting source xml to target xml using xstl . I have below two questions :

 

1. How to the get a value of element <ns0:SID>4567</ns0:SID> from source XML to Target XML element <urn:sessionId /> using XSTL

2. How to delete element <ns0:SID>4567</ns0:SID> when source XML transforms to Target XML

 

Below are the source XML, XSTL 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>

 

XSTL 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

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...