How can I convert the string date "Wednesday, April 25, 2018 - 11:00" coming from input xml to 2018-04-25 11:00 AM format in my xslt code.
following is the input xml which is coming from RSS feed and cant be changed.
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://www.hhs.gov/rss/news.xml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Latest News Releases</title>
<link>https://www.hhs.gov/rss/news.xml</link>
<description>HHS News Releases</description>
<language>en</language>
<atom:link href="https://www.hhs.gov/rss/news.xml" rel="self" type="application/rss+xml" />
<item>
<title>Secretary Azar, Surgeon General Adams Praise Private Sector Support for Naloxone Advisory</title>
<link>https://www.hhs.gov/about/news/2018/04/25/secretary-azar-surgeon-general-adams-praise-private-sector-support-naloxone-advisory.html</link>
<description><p>Following the early April release of the Surgeon General’s Advisory on Naloxone and Opioid Overdose
</description>
<pubDate>Wednesday, April 25, 2018 - 11:00</pubDate>
<dc:creator>HHS Press Office</dc:creator>
<guid isPermaLink="true">https://www.hhs.gov/about/news/2018/04/25/secretary-azar-surgeon-general-adams-praise-private-sector-support-naloxone-advisory.html</guid>
</item>
</channel>
</rss>
Here is the XSL I have written
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/rss">
<Records>
<xsl:apply-templates select="channel/item" />
</Records>
</xsl:template>
<xsl:template match="channel/item">
<xsl:element name="Record">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
The output i am getting is below. Notice the date is coming as string which is causing my feed to fail. How can I convert the string date "Wednesday, April 25, 2018 - 11:00" to 2018-04-25 11:00 AM format
<Record>
<title>Secretary Azar, Surgeon General Adams Praise Private Sector Support for Naloxone Advisory</title>
<link>https://www.hhs.gov/about/news/2018/04/25/secretary-azar-surgeon-general-adams-praise-private-sector-support-naloxone-advisory.html</link>
<description><p>Following the early April release of the Surgeon General’s Advisory on Naloxone and Opioid Overdose
</description>
<pubDate>Wednesday, April 25, 2018 - 11:00</pubDate>
<creator>HHS Press Office</creator>
<guid isPermaLink="true">https://www.hhs.gov/about/news/2018/04/25/secretary-azar-surgeon-general-adams-praise-private-sector-support-naloxone-advisory.html</guid>
</Record>