From what I read on the internet, this ought to be a simple task to accomplish, but I can't seem to get XSLT to do what I need...
Am receiving an XML message and I need to create an identical output XML message except with some of the element names replaced. In the input message below, I would like to rename element "Message" to "ReturnMsg" and "string" to "DataString".
Any help would be appreciated. Would also be interested in recommendations for a good reference site for XML/XPATH/XSLT on the web.
Code what you mean,
and mean what you code!
But by all means post your code!
Razalas
Am receiving an XML message and I need to create an identical output XML message except with some of the element names replaced. In the input message below, I would like to rename element "Message" to "ReturnMsg" and "string" to "DataString".
Any help would be appreciated. Would also be interested in recommendations for a good reference site for XML/XPATH/XSLT on the web.
Code:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/envelope/"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
<soap:Body>
<GetShippersListResponse xmlns="[URL unfurl="true"]http://adsionline.com/ADSIShippingWS/">[/URL]
<GetShippersListResult>
<Success>true</Success>
<Message />
<ResponseList>
<string>RSR</string>
</ResponseList>
</GetShippersListResult>
</GetShippersListResponse>
</soap:Body>
</soap:Envelope>
Code:
<?xml version="1.0"?>
<xsl:transform version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:soapenv="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/envelope/">[/URL]
<xsl:strip-space elements="*"/>
<xsl:template match="soapenv:*">
<xsl:apply-templates select="@* | node()" />
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="//Message">
<xsl:element name="ReturnMsg">
<xsl:value-of select="Message" />
</xsl:element>
</xsl:template>
<xsl:template match="//string">
<xsl:element name="DataString">
<xsl:value-of select="string" />
</xsl:element>
</xsl:template>
</xsl:transform>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<GetShippersListResponse xmlns="[URL unfurl="true"]http://adsionline.com/ADSIShippingWS/">[/URL]
<GetShippersListResult>
<Success>true</Success>
<Message/>
<ResponseList>
<string>RSR</string>
</ResponseList>
</GetShippersListResult>
</GetShippersListResponse>
Code what you mean,
and mean what you code!
But by all means post your code!
Razalas