I'm using XSLT 1.0 for transforming an XML(input) to another XML(output). I ran into problem where I'm not able to transform one of the element of a particular node in the XSLT.
Here is my input XML :
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<payload>
<order>
<Id>12345</Id>
<dateDelivery>2018-03-29T14:00:00 EST</dateDelivery>
<play>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</play>
<play>
<title>Esque</title>
<artist>Bylan</artist>
<country>CA</country>
<company>bia</company>
<price>16.90</price>
<year>2018</year>
</play>
</order>
</payload>
</cd>
</catalog>
XSLT :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body>
<SongUpdate_Request>
<xsl:apply-templates select="//cd"/>
</SongUpdate_Request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</xsl:template>
<xsl:template match="//cd">
<xsl:call-template name="getHeader"/>
<xsl:call-template name="getPayload"/>
</xsl:template>
<xsl:template name="getHeader">
<header>
<header>
<Id_T>
<xsl:value-of select="//payload/order/Id"/>
</Id_T>
</header>
</header>
</xsl:template>
<xsl:template name="getPayload">
<songEvent>
<xsl:call-template name="getOrder"/>
</songEvent>
</xsl:template>
<xsl:template name="replace">
<xsl:param name="dd"/>
<xsl:param name="searchString"> EST</xsl:param>
<xsl:param name="replaceString">.000Z</xsl:param>
<xsl:choose>
<xsl:when test="contains($dd,$searchString)">
<xsl:value-of select="substring-before($dd,$searchString)"/>
<xsl:value-of select="$replaceString"/>
<!-- recursive call -->
<xsl:call-template name="replace">
<xsl:with-param name="dd" select="substring-after($dd,$searchString)"/>
<xsl:with-param name="searchString" select="$searchString"/>
<xsl:with-param name="replaceString" select="$replaceString"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$dd"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="getOrder">
<xsl:call-template name="replace">
<xsl:with-param name="dd" select="//*:payload/*:order/*:dateDelivery"/>
</xsl:call-template>
<xsl:variable name="OrderPresent">
<xsl:value-of select=".//*:order"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$OrderPresent!=''">
<xsl:copy-of select=".//*:order"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Output XML :
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SongUpdate_Request>
<header>
<header>
<Id_T>12345</Id_T>
</header>
</header>
<songEvent>2018-03-29T14:00:00.000Z
<order>
<Id>12345</Id>
<dateDelivery>2018-03-29T14:00:00 EST</dateDelivery>
<play>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</play>
<play>
<title>Esque</title>
<artist>Bylan</artist>
<country>CA</country>
<company>bia</company>
<price>16.90</price>
<year>2018</year>
</play>
</order>
</songEvent>
</SongUpdate_Request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
So if you observer, I'm trying to change the date format from EST to "Z". But I'm not sure how to apply while transforming in the XSLT. Meaning I want to see the output xml like :
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SongUpdate_Request>
<header>
<header>
<Id_T>12345</Id_T>
</header>
</header>
<songEvent>
<order>
<Id>12345</Id>
*<dateDelivery>2018-03-29T14:00:00.000Z</dateDelivery>*
<play>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</play>
<play>
<title>Esque</title>
<artist>Bylan</artist>
<country>CA</country>
<company>bia</company>
<price>16.90</price>
<year>2018</year>
</play>
</order>
</songEvent>
</SongUpdate_Request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Any suggestions or help is greatly appreciated. Thanks!!
2018-03-29T14:00:00 EST
is actually2018-03-29T19:00:00 Z
? – michael.hor257k$100
to€100
without converting the amount using the exchange rate. – michael.hor257k