Reputation: 31
I am trying to extract using the following
<xsl:template match="//alarms:alarmRaisedTime">
<xsl:variable name="secondsSince1970" select="(xs:dateTime(.) - xs:dateTime('1970-01-01T00:00:00')) div xs:dayTimeDuration('PT1S')" />
<xsl:element name="alarmRaisedTime" namespace="MY NAME SPACE">
<xsl:value-of select="$secondsSince1970"/>
</xsl:element>
</xsl:template>
Output I get is
<alarmRaisedTime>1367855105.001</alarmRaisedTime>
I would like to get the below given output (Note Milli Seconds is removed)
<alarmRaisedTime>1367855105</alarmRaisedTime>
I tried the following:
<xsl:value-of select="fn:substring-before($secondsSince1970,.)"/>
but it did not work.
Upvotes: 3
Views: 54
Reputation: 243449
Even simpler:
floor($secondsSince1970)
By definition:
The floor function returns the largest (closest to positive infinity) number that is not greater than the argument and that is an integer.
Upvotes: 2
Reputation: 7044
Try
<xsl:value-of select="fn:substring-before($secondsSince1970,'.')"/>
The .
in your expression refers to the context item alarms:alarmsRaisedTime
Upvotes: 1