<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com">
<soapenv:Body>
<upsertResponse>
<result>
<created>true</created>
<id>0011</id>
<success>true</success>
</result>
<result>
<created>false</created>
<id>0012</id>
<success>true</success>
</result>
</upsertResponse>
</soapenv:Body>
</soapenv:Envelope>
**How can I transform this to**
<upsertResponse>
<result>
<created>true</created>
<id>0011</id>
<success>true</success>
</result>
<result>
<created>false</created>
<id>0012</id>
<success>true</success>
</result>
</upsertResponse>
views:
355answers:
2
A:
Use an <xsl:match> to select the <upsertResponse> element, then put an <xsl:copy> inside of it. That should do the trick. Sorry I don't have the exact syntax, but hopefully this points you in the right direction.
Jerry Bullard
2009-10-19 20:57:59
What's an `<xsl:match>`?
Tomalak
2009-10-20 08:53:55
Sorry. I meant "xsl:template match". It has been a while.
Jerry Bullard
2009-10-21 03:45:37
A:
This is an example of XSL that takes the first child of first child of root and makes it root node of new XML:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="./*[1]/*[1]/*[1]" />
</xsl:template>
</xsl:stylesheet>
Please note that you can take only one node and not multiple nodes since placing few nodes as root of XML is not valid.
Elisha
2009-10-19 21:16:36
This is working perfectly,Except that the root node now has a Namespace assigned.<?xml version="1.0" encoding="UTF-8"?><upsertResponse xmlns="urn:enterprise.soap.sforce.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <result> <created>true</created> <id>0011</id> <success>true</success> </result> <result> <created>false</created> <id>0012</id> <success>true</success> </result></upsertResponse>
Shree
2009-10-19 22:17:13
In XML the decedents are implicitly part of the namespace or their parent (unless declared explicitly other namespace). Since the original parent does not appear in the new XML the new root explicitly declares it.
Elisha
2009-10-20 04:12:27