This question is unique in that fact that I had a look at the two answers that came up as being similar - and those did not solve my problem. I want the timeShift field to be added to the html as a text value and not as a property of the tag.
I have the following xml, and would like to do some time manipulation on the timeShift field, in order for it to be in the format: HH:MM:SS.
How can I do this in xsl?
The following is my current xsl file:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:key name="party" match="newParty" use="@userId" />
<xsl:template match="/chatTranscript">
<html>
<head><link rel="stylesheet" type="text/css" href="/webrecall/css/chat.css"/></head>
<header>Chat - <xsl:value-of select="@sessionId" /> - <xsl:value-of select="@startAt" /></header>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="newParty[userInfo/@userType='CLIENT']">
<div class="ClientJoined" id="{@userId}">
<label>Client: <xsl:value-of select="userInfo/@userNick" /></label>
<label class="timeShiftLabel"><xsl:value-of select="@timeShift" /></label>
</div>
</xsl:template>
<xsl:template match="newParty[userInfo/@userType='AGENT']">
<div class="AgentJoined" id="{@userId}">
<label>Agent: <xsl:value-of select="userInfo/@userNick" /></label>
<label class="timeShiftLabel"><xsl:value-of select="@timeShift" /></label>
</div>
</xsl:template>
<xsl:template match="message">
<xsl:variable name="party-class">
<xsl:call-template name="lookup-class"/>
</xsl:variable>
<div class="Messages {$party-class}" id="{@eventId}">
<label><xsl:value-of select="msgText" /></label>
<label class="timeShiftLabel"><xsl:value-of select="@timeShift" /></label>
</div>
</xsl:template>
<xsl:template match="notice">
<xsl:variable name="party-class">
<xsl:call-template name="lookup-class"/>
</xsl:variable>
<div class="Notices {$party-class}" id="{@eventId}">
<label><xsl:value-of select="noticeText" /></label>
<label class="timeShiftLabel"><xsl:value-of select="@timeShift" /></label>
</div>
</xsl:template>
<xsl:template match="partyLeft">
<xsl:variable name="party-class">
<xsl:call-template name="lookup-class"/>
</xsl:variable>
<div class="Notices {$party-class}" id="{@eventId}">
<label><xsl:value-of select="reason" /></label>
<label class="timeShiftLabel"><xsl:value-of select="@timeShift" /></label>
</div>
</xsl:template>
<xsl:template name="lookup-class">
<xsl:variable name="party-type" select="key('party', @userId)/userInfo/@userType" />
<xsl:choose>
<xsl:when test="$party-type='CLIENT'">Client</xsl:when>
<xsl:when test="$party-type='AGENT'">Agent</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
The following is the xml:
<?xml version="1.0"?><chatTranscript startAt="2015-06-04T09:07:40Z" sessionId="0003CaANX11G00HD">
<newParty userId="00955570155B0000" eventId="1" timeShift="0" visibility="ALL">
<userInfo personId="" userNick="PhilC" userType="CLIENT" protocolType="FLEX" timeZoneOffset="120"/>
<userData>
<item key="EmailAddress"/>
<item key="FirstName">Phil</item>
<item key="IdentifyCreateContact">3</item>
<item key="LastName">Collins</item>
<item key="MediaType">chat</item>
</userData>
</newParty>
<newParty userId="0095557015600002" eventId="2" timeShift="4" visibility="ALL">
<userInfo personId="" userNick="system" userType="EXTERNAL" protocolType="ESP" timeZoneOffset="0"/>
</newParty>
<message userId="0095557015600002" eventId="3" timeShift="4" visibility="ALL">
<msgText>agent will be with you shortly</msgText>
</message>
<newParty userId="00955570156E0003" eventId="4" timeShift="19" visibility="ALL">
<userInfo personId="emailqa" userNick="emailqa" userType="AGENT" protocolType="BASIC" timeZoneOffset="120"/>
</newParty>
<message userId="00955570155B0000" eventId="6" timeShift="22" visibility="ALL">
<msgText msgType="text" treatAs="NORMAL">hellO?</msgText>
</message>
<message userId="00955570156E0003" eventId="9" timeShift="26" visibility="ALL">
<msgText treatAs="NORMAL">hi Phil</msgText>
</message>
<message userId="00955570156E0003" eventId="11" timeShift="28" visibility="ALL">
<msgText treatAs="NORMAL">whatsup?</msgText>
</message>
<message userId="00955570155B0000" eventId="14" timeShift="45" visibility="ALL">
<msgText msgType="text" treatAs="NORMAL">we're sitting next to each other but we're sending IMs </msgText>
</message>
<message userId="00955570156E0003" eventId="17" timeShift="54" visibility="ALL">
<msgText treatAs="NORMAL">hehehe</msgText>
</message>
<message userId="00955570156E0003" eventId="19" timeShift="56" visibility="ALL">
<msgText treatAs="NORMAL">indeed</msgText>
</message>
<partyLeft userId="00955570156E0003" askerId="00955570156E0003" eventId="21" timeShift="77" visibility="ALL">
<reason code="1">left with request to close if no agents</reason>
</partyLeft>
<partyLeft userId="00955570155B0000" askerId="00955570156E0003" eventId="22" timeShift="77" visibility="ALL">
<reason code="4">removed by other party</reason>
</partyLeft>
</chatTranscript>
So the question is how can I take the timeShift integer value as input(its indicative of the time lapsed in seconds), and manipulate it to be a duration, in the format HH:mm:ss.