I could not able to access PartNumber/Description value under attribute tag with below xpath but and soap xml is given below.Let me know any further details required.
Please help on this.Thanks inadvance!.
Xpath being used And SOAP XML Message:
<xsl:value-of select="/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='PullCustomerPartsPricingResponse']/*[local-name()='PullCustomerPartsPricingResult']/*[local-name()='CustomerPart']/#*[local-name()='PartNumber']"/>
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header />
<s:Body>
<PullCustomerPartsPricingResponse xmlns="http://cdx.dealerbuilt.com/Api/0.99/">
<PullCustomerPartsPricingResult xmlns:a="http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:CustomerPart>
<a:Placement>
<a:GroupId>10</a:GroupId>
</a:Placement>
<a:Attributes xmlns:b="http://schemas.datacontract.org/2004/07/DealerBuilt.Models.Parts">
<b:AddedDate>2017-12-19T00:00:00</b:AddedDate>
<b:DealerPartId>287925</b:DealerPartId>
<b:Description>BAT (51/500AMP85)</b:Description>
<b:PartNumber>31500SB2yy1M</b:PartNumber>
<b:QuantityLostMonthToDate>0</b:QuantityLostMonthToDate>
</a:Attributes>
<a:PartKey>GZ287925</a:PartKey>
<a:CustomerListPrice xmlns:b="http://schemas.datacontract.org/2004/07/DealerBuilt.Models">
<b:Amount>130.49</b:Amount>
<b:Currency>UsDollar</b:Currency>
</a:CustomerListPrice>
</a:CustomerPart>
</PullCustomerPartsPricingResult>
</PullCustomerPartsPricingResponse>
</s:Body>
</s:Envelope>
Regards
Vardhan
You have ended your long xpath expression with this..
/#*[local-name()='PartNumber']
But PartNumber is not an attribute. It is an element named PartNumber that is a child of an element that happened to be named Attributes, but that does not actually make it an attribute in XML terms!
It should look like this...
<xsl:value-of select="/*[local-name()='Envelope']
/*[local-name()='Body']
/*[local-name()='PullCustomerPartsPricingResponse']
/*[local-name()='PullCustomerPartsPricingResult']
/*[local-name()='CustomerPart']
/*[local-name()='Attributes']
/*[local-name()='PartNumber']"/>
Although it would be really better if you declared the namespaces in your XSLT and used then in your xpath.
NameSpaces from the request XML need to be used in xslt as well.Following xsl gave the PartNumber value.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://schemas.datacontract.org/2004/07/DealerBuilt.Models.Parts">
<xsl:output method="xml" version="1.0"/>
<xsl:template match="/">
<xsl:value-of select="*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='PullCustomerPartsPricingResponse']/*[local-name()='PullCustomerPartsPricingResult']/*[local-name()='CustomerPart']/*[local-name()='Attributes']/*[local-name()='PartNumber']"/>
</xsl:template>
</xsl:stylesheet>
Related
I have an XML document with a default namespace indicated at the root.
Something like this:
<MyRoot xmlns="http://www.mysite.com">
<MyChild1>
<MyData>1234</MyData>
</MyChild1>
</MyRoot>
The XSLT to parse the XML does not work as expected because of the
default namespace, i.e. when I remove the namespace, everything works as
expected.
Here is my XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/" >
<soap:Envelope xsl:version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NewRoot xmlns="http://wherever.com">
<NewChild>
<ChildID>ABCD</ChildID>
<ChildData>
<xsl:value-of select="/MyRoot/MyChild1/MyData"/>
</ChildData>
</NewChild>
</NewRoot>
</soap:Body>
</soap:Envelope>
</xsl:template>
</xsl:stylesheet>
What needs to be done with XSLT document so that translation works properly? What exactly needs to be done in XSLT document?
You need to declare the namespace in your XSLT, and use it in XPath expressions. E.g.:
<xsl:stylesheet ... xmlns:my="http://www.mysite.com">
<xsl:template match="/my:MyRoot"> ... </xsl:template>
</xsl:stylesheet>
Note that you must provide some prefix if you want to refer to elements from that namespace in XPath. While you can just do xmlns="..." without the prefix, and it will work for literal result elements, it won't work for XPath - in XPath, an unprefixed name is always considered to be in namespace with blank URI, regardless of any xmlns="..." in scope.
If you use XSLT 2.0, specify xpath-default-namespace="http://www.example.com" in the stylesheet section.
If this was kind of name space problem, there is room to try to modify two things in the xslt file:
add "my" name space definition in xsl:stylesheet tag
use "my:" prefix when call elements in traversing the xml file.
result
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:my="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/" >
<soap:Envelope xsl:version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NewRoot xmlns="http://wherever.com">
<NewChild>
<ChildID>ABCD</ChildID>
<ChildData>
<xsl:value-of select="/my:MyRoot/my:MyChild1/my:MyData"/>
</ChildData>
</NewChild>
</NewRoot>
</soap:Body>
</soap:Envelope>
</xsl:template>
</xsl:stylesheet>
I want to convert below code to some formatted xml code,
Input For XSLT Transformation:
<soap:Envelope
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<rejectQuoteXMLResponse
xmlns='http://xxx.group.com'>
<out>
<![CDATA[
<TFGCPLResultXMLDO>
<processInstanceName>reejectQuoteXML</processInstanceName>
<duration>0</duration>
<accumulatedNumberOfExceptions>0</accumulatedNumberOfExceptions>
<accumulatedNumberOfErrors>0</accumulatedNumberOfErrors>
<accumulatedNumberOfWarnings>0</accumulatedNumberOfWarnings>
<numOfExceptions>0</numOfExceptions>
<numOfErrors>0</numOfErrors>
<numOfWarnings>0</numOfWarnings>
<BusinessMessages>
<BusinessErrors/>
<BusinessWarnings/>
<BusinessGenericMessages/>
</BusinessMessages>
<requestedTransSuccessfulInd>true</requestedTransSuccessfulInd>
<modifySuccessfulInd>false</modifySuccessfulInd>
<copySuccessfulInd>false</copySuccessfulInd>
<responseXMLString>
<RejectPolicyRes>
<status>Success</status>
<message>Reject Policy successful</message>
</RejectPolicyRes>
</responseXMLString>
</TFGCPLResultXMLDO>
]]>
</out>
</rejectQuoteXMLResponse>
</soap:Body>
</soap:Envelope>
Required Output:
<QuoteRejectRs>
<UserId>344758</UserId>
<QuoteDetails>
<QuoteNumber>PA-Q450000</QuoteNumber>
<Status>Success</Status>
<Message>Reject Policy successful</Message>
</QuoteDetails>
</QuoteRejectRs>
XSLT Transformation code:
<!-- <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:md1="http://http://xxx.group.com" xmlns:exsl="http://exslt.org/common"
exclude-result-prefixes="xs md1"
extension-element-prefixes="exsl"
version="2.0"> -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<!--XML Response for Quote Reject which tell request has been submitted with success or fail -->
<QuoteRejectRs>
<UserId></UserId>
<QuoteDetails>
<QuoteNumber></QuoteNumber>
<Status>
<xsl:value-of select="substring-before(substring-after(.,'Envelope/Body/TFGCPLResultXMLDO>'), '<Envelope/Body/TFGCPLResultXMLDO/responseXMLString/RejectPolicyRes/status')"/>
</Status>
<Message>
<xsl:value-of select="substring-before(substring-after(.,'Envelope/Body/TFGCPLResultXMLDO>'), '<Envelope/Body/TFGCPLResultXMLDO/responseXMLString/RejectPolicyRes/message')"/>
</Message>
<!-- <Status><xsl:value-of select="soap:Envelope/soap:Body/md1:rejectQuoteXMLResponse/md1:out/md1:status"/></Status><Message><xsl:value-of select="Envelope/Body/TFGCPLResultXMLDO/responseXMLString/RejectPolicyRes/message"/></Message>-->
</QuoteDetails>
</QuoteRejectRs>
</xsl:template>
</xsl:stylesheet>
I have tried and able to convert xml which contains namespace (soap:xxx) , but unable to convert xml which contains CDATA.
I have tried but getting response containing < > format.
So anyone know solution for such task.
You complain that you are
getting response containing < > format.
That's easy enough to fix. xsl:value-of has an attribute disable-output-escaping specifically for that purpose, so something like
<Status>
<xsl:value-of
select="substring-before(substring-after(.,'Envelope/Body/TFGCPLResultXMLDO>'), '<Envelope/Body/TFGCPLResultXMLDO/responseXMLString/RejectPolicyRes/status')"
disable-output-escaping="yes"/>
</Status>
<Message>
<xsl:value-of
select="substring-before(substring-after(.,'Envelope/Body/TFGCPLResultXMLDO>'), '<Envelope/Body/TFGCPLResultXMLDO/responseXMLString/RejectPolicyRes/message')"
disable-output-escaping="yes"/>
</Message>
ought to do the job you seem to be looking for.
HOWEVER, I urge you to take a different approach. Picking apart and parsing XML text via string functions is bad news. What you really should do is parse the embedded XML as an XML document, and transform that. Unfortunately, XSLT 1.0 and 2.0 do not have a standard mechanism for that, but some implementations add that as an extension, and depending on how you are performing the transformation, it may be comparatively easy to install your own extension function for the purpose. Alternatively, you could extract the embedded XML as a preliminary step, and then transform just that.
I have a incoming SOAP message like below:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns3:GetImageResponse xmlns="urn:webservice/server/mobile/shoebox/types/v1/CustomImage" xmlns:ns2="urn:webservice/server/mobile/shoebox/types/v1/common/ShoeboxCommonArtifacts" xmlns:ns3="urn:webservice/server/mobile/shoebox/types/v1/Image" xmlns:ns4="urn:webservice/server/mobile/shoebox/types/v1/common/exceptions" xmlns:ns5="urn:webservice/server/mobile/shoebox/types/v1/GetThumbnailImage">
<ns3:returnCode>105</ns3:returnCode>
<ns3:errorText>Invalid Participant code/id.</ns3:errorText>
<ns3:shoeboxImage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</ns3:GetImageResponse>
</soap:Body>
</soap:Envelope>
Need to transform into another simple XML like Below: (Constraint - The root element under BODY of SOAP envelope (ex- if "GetImageResponse" coming we need construct "GetImage" element in output XML) and it is not constant it can be any element So need to construct XML based on the root element under BODY , Ex shown below)
<?xml version="1.0" encoding="UTF-8"?>
<tns:GetImage xmlns:bons1="http://highmark.com/rbssvc/messages/common" xmlns:tns="http://www.example.org/GetImageResponseMessage/" xmlns:tns1="http://www.example.org/GetImageResponse/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/GetImageResponseMessage/ ../xsd/GetImageResponseMessage.xsd ">
<payload>
<returnCode>returnCode</returnCode>
<errorText>errorText</errorText>
<imageData>MA==</imageData>
</payload>
I am using this below XSLT to transform:
<xsl:stylesheet extension-element-prefixes="dp" exclude-result-prefixes="dp regex" version="1.0" xmlns:dp="http://www.datapower.com/extensions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:regex="http://exslt.org/regular-expressions">
<xsl:template match="/">
<GetImage>
<xsl:element name="{'Payload'}">
<xsl:copy-of select="/*/*[local-name()='Body']/*[local-name()='GetImageResponse']/*"/>
</xsl:element>
</GetImage>
</xsl:template>
</xsl:stylesheet>
But i am not getting the desired XML output shown above
The out put which i am getting is :
<GetImageResponse>
<Payload>
<ns3:returnCode xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns5="urn:webservice/server/mobile/shoebox/types/v1/GetThumbnailImage" xmlns:ns4="urn:webservice/server/mobile/shoebox/types/v1/common/exceptions" xmlns:ns3="urn:webservice/server/mobile/shoebox/types/v1/Image" xmlns:ns2="urn:webservice/server/mobile/shoebox/types/v1/common/ShoeboxCommonArtifacts" xmlns="urn:webservice/server/mobile/shoebox/types/v1/CustomImage">105</ns3:returnCode>
<ns3:errorText xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns5="urn:webservice/server/mobile/shoebox/types/v1/GetThumbnailImage" xmlns:ns4="urn:webservice/server/mobile/shoebox/types/v1/common/exceptions" xmlns:ns3="urn:webservice/server/mobile/shoebox/types/v1/Image" xmlns:ns2="urn:webservice/server/mobile/shoebox/types/v1/common/ShoeboxCommonArtifacts" xmlns="urn:webservice/server/mobile/shoebox/types/v1/CustomImage">Invalid Participant code/id.</ns3:errorText>
<ns3:shoeboxImage xsi:nil="true" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns5="urn:webservice/server/mobile/shoebox/types/v1/GetThumbnailImage" xmlns:ns4="urn:webservice/server/mobile/shoebox/types/v1/common/exceptions" xmlns:ns3="urn:webservice/server/mobile/shoebox/types/v1/Image" xmlns:ns2="urn:webservice/server/mobile/shoebox/types/v1/common/ShoeboxCommonArtifacts" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:webservice/server/mobile/shoebox/types/v1/CustomImage"/>
</Payload>
</GetImageResponse>
The issue is here like i am not able to copy the name space of incoming soap message Like element "GetImageResponse" and some extra namespace are also coming for element "payload" .enter code here
Any idea how i can transform from SOAP message to the desired XML output.
Quick reply appreciated.
Regards
Rj
Well the redundant xmlns declarations are visual noise, but functionally not a problem. However you can fix this by making sure you set the necessary xmlns declarations on the root element of the result that you generate. In your case this is: <GetImage>.
You'll note that in your stylesheet the GetImage element is in the default namespace of the document which contains the XSLT stylesheet, which is also not specified.
Example:
<!--
namespace GetImage and
set up additional namespace mapping for ns5 prefix
for any copied elements which may be injected
-->
<tns:GetImage xmlns:tns="tns-uri" xmlns:ns5="ns5-uri">
<!-- more stuff here -->
</tns:GetImage>
Next up your <xsl:element name="{'Payload'}"> call also does not inject a namespace. You can either use the namespace attribute of xsl:element to associate the generated element with the desired namespace (URI), or you can use the syntax {prefix}:{local-name} in the name attribute and add the appropriate xmlns:prefix declarations.
Examples:
<xsl:element name="foo" namespace="bar"/>
<!-- needs xmlns:ns declaration -->
<xsl:element name="ns:foo"/>
<!-- substantially the same, using 'expressions' instead of 'literals' -->
<xsl:element name="{$nsPrefix}:{local-name()}">
Your question is not entirely clear. I think you want to do something like this:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns3="urn:webservice/server/mobile/shoebox/types/v1/Image"
xmlns:my="http://www.example.com/my"
exclude-result-prefixes="soap ns3 my">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<my:ns-holder xmlns:bons1="http://highmark.com/rbssvc/messages/common" xmlns:tns1="http://www.example.org/GetImageResponse/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/GetImageResponseMessage/ ../xsd/GetImageResponseMessage.xsd "/>
<xsl:template match="/soap:Envelope/soap:Body/*">
<xsl:element name="tns:{local-name()}" xmlns:tns="http://www.example.org/GetImageResponseMessage/">
<xsl:copy-of select="document('')/xsl:stylesheet/my:ns-holder/namespace::*"/>
<payload>
<returnCode>
<xsl:value-of select="ns3:returnCode" />
</returnCode>
<errorText>
<xsl:value-of select="ns3:errorText" />
</errorText>
<imageData>MA==</imageData>
</payload>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
What this does is:
Create a root element whose local name is the same as the name of
the child of soap:Body, assign it a tns: prefix and bind the
prefix to the "http://www.example.org/GetImageResponseMessage/'
namespace. Note that this assumes there will be only one such child.
Add a bunch of namespaces to the above root element. Note that these
namespaces are not actually used in the result - and as such are
entirely redundant.
Create the payload and its value nodes. Note that you cannot use
xsl:copy here, because that would also copy the original node's
namespace (ns3 in this example).
Applied to your input example, the result here will be:
<?xml version="1.0" encoding="UTF-8"?>
<tns:GetImageResponse xmlns:tns="http://www.example.org/GetImageResponseMessage/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="urn:webservice/server/mobile/shoebox/types/v1/Image" xmlns:my="http://www.example.com/my" xmlns:bons1="http://highmark.com/rbssvc/messages/common" xmlns:tns1="http://www.example.org/GetImageResponse/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<payload>
<returnCode>105</returnCode>
<errorText>Invalid Participant code/id.</errorText>
<imageData>MA==</imageData>
</payload>
</tns:GetImageResponse>
I did not understand:
How exactly should GetImageResponse be tranformed into GetImage;
Where is the imageData value ("MA==") supposed to come from.
I need to parse the following node:
<media:keywords>keyword1,keyword2<![CDATA[keyword3]]></media:keywords>
into a valid string, preferably "keyword1,keyword2,keyword3" but I would settle for removing the cdata completely.
Trying to access the node gives me the text "keyword1,keyword2keyword3" and I can't tell where the CDATA begins.
original xml (simplified version of mRSS feed)
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<item>
<media:keywords>keyword1,keyword2<![CDATA[keyword3]]></media:keywords>
</item>
</channel>
</rss>
xsl (simplified):
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:media="http://search.yahoo.com/mrss/" exclude-result-prefixes="xs xsi fn">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<test>
<xsl:variable name="items" select="/rss/channel/item"/>
<xsl:for-each select="$items">
<xsl:variable name="mediakw" select="media:keywords"/>
<xsl:element name="mediaKeyWords">
<xsl:value-of select="$mediakw"/>
</xsl:element>
</xsl:for-each>
</test>
</xsl:template>
</xsl:stylesheet>
and the output:
<test xmlns:media="http://search.yahoo.com/mrss/"><mediaKeyWords>keyword1,keyword2keyword3</mediaKeyWords></test>
Thanks a lot!
XML and XSLT cannot help you here.
XSLT uses the INFOSET model in which there isn't anything as a "CDATA node" and there is just a single text() node:
"keyword1,keyword2keyword3"
The XML document needs to be corrected and a comma be inserted between the substrings "keyword2" and "keyword3"
One solution would be to process the CDATA DOM node using DOM, and only then initiate the XSLT transformation.
By the time the XSLT processor sees the text, the CDATA is gone. You cannot see the incoming CDATA, and have very little control over how output CDATA is generated (all or nothing for a given tag).
Can't be done in standard XSLT.
The input XML you're receiving,
<media:keywords>keyword1,keyword2<![CDATA[keyword3]]></media:keywords>
is indistinguishable (to XSLT) from
<media:keywords>keyword1,keyword2keyword3</media:keywords>
because the CDATA markup is just a way of escaping the data inside it. There is really no special markup to escape in this case, so the CDATA happens to be a no-op. But XSLT has no way of knowing what data was originally expressed using CDATA, what was expressed using character entities, etc.
The solution would be to tell whoever is providing this XML that they need to put a delimiter between keyword2 and keyword3.
I am struggling with what should be a simple XSL: Copy the updateResponse from the message below (note: I need XPATH 1.0 syntax for my integration system compatibility):
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com" xmlns:n="urn:enterprise.soap.sforce.com">
<soapenv:Body>
<updateResponse>
<result>
<id>001S000000J1Bu0IAF</id>
<success>true</success>
</result>
</updateResponse>
</soapenv:Body>
</soapenv:Envelope>
I simply want the result structure to be:
<updateResponse xmlns="urn:enterprise.soap.sforce.com">
<result>
<id>001S000000J1Bu0IAF</id>
<success>true</success>
</result>
</updateResponse>
I am able to copy the soap objects, but am unsuccessful in copying the children of the soapenv:Body element. The first copy-of works for Body, but the second does not resolve the XPATH. My XMLSPY tool xpath query editor says the xpath is valid, but the XSL does not resolve.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:urn="enterprise.soap.sforce.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:namespace-alias stylesheet-prefix="soapenv" result-prefix="foo"/>
<xsl:template match="/">
<xsl:apply-templates select="/soapenv:Envelope/soapenv:Body/urn:updateResponse"/>
</xsl:template>
<xsl:template match="/soapenv:Envelope/soapenv:Body/urn:updateResponse">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Your namespaces are mismatched between your data and your stylesheet, that seems to be the only problem.
In your stylesheet document, change this:
xmlns:urn="enterprise.soap.sforce.com"
to this:
xmlns:urn="urn:enterprise.soap.sforce.com"
Then it will match the declared namespaces in your original input file.
This stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:template match="/soapenv:Envelope/soapenv:Body//*">
<xsl:element name="{local-name()}"
namespace="urn:enterprise.soap.sforce.com">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Output:
<updateResponse xmlns="urn:enterprise.soap.sforce.com">
<result>
<id>001S000000J1Bu0IAF</id>
<success>true</success>
</result>
</updateResponse>
Note: First, the namespace declaration in your stylesheet is wrong. It should be xmlns:urn="urn:enterprise.soap.sforce.com". Second, for an exact result you need to strip in scope namespaces (there are three: xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/", xmlns="urn:enterprise.soap.sforce.com" (default), and xmlns:n="urn:enterprise.soap.sforce.com)
The namespaces in this document are weird; you have xmlns and xmlns:n both assigned to the same namespace. It looks like //soapenv:updateResponse should work. Have you tried that?