Jump to content

XML Transformation using XSTL -get value-of select


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...