I’m attempting to make an XML log file a bit more readable via XSLT.
It has several events within the log and the times are in dateTime format and would like to select the events which occurred on a specific (single) date.
Here is an excerpt from my log.xml file:
<event>
<bag>168</bag>
<action>Check Out</action>
<time>2011-04-07T11:41:34.7219171-04:00</time>
<user>jroderick</user>
</event>
<event>
<bag>168</bag>
<action>Check In</action>
<time>2011-04-07T11:41:38.7079901-04:00</time>
<user>jroderick</user>
</event>
<event>
<bag>1147</bag>
<action>Check In</action>
<time>2011-04-07T14:27:14.0662271-04:00</time>
<user>jholby</user>
</event>
In my log.xsl I have the following for the table I want to generate: one row per event.
<xsl:for-each select="log/event">
<xsl:if test="???">
<tr>
<td>
<xsl:value-of select="user"/>
</td>
<td>
<xsl:value-of select="time"/>
</td>
<td>
<xsl:value-of select="action"/>
</td>
</tr>
</xsl:if>
I was hoping there was a rather simplistic way to achieve this in the 2.0 functions but I haven’t been able to locate anything.
Attempted to cast the dateTime into an xs:date but without any luck using Saxon 9.3 HE for .Net.
Any help would be greatly appreciated!
This XSLT 2.0 stylesheet:
Output:
Note: Your data is in
xs:dateTimeformat, so you need to cast first as this. Do take care of time zone