c# - XSLT Compare Date to a Date portion of DateTime -


i'm attempting make xml log file bit more readable via xslt.

it has several events within log , times in datetime format , select events occurred on specific (single) date.

here excerpt 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 log.xsl have following table want generate: 1 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 hoping there rather simplistic way achieve in 2.0 functions haven't been able locate anything.

attempted cast datetime xs:date without luck using saxon 9.3 .net.

http://saxon.sourceforge.net/

any appreciated!

this xslt 2.0 stylesheet:

<xsl:stylesheet version="2.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform"  xmlns:xs="http://www.w3.org/2001/xmlschema"  exclude-result-prefixes="xs">     <xsl:template match="/">         <result>             <xsl:for-each              select="log/event[                         xs:date(xs:datetime(time))                       eq                         xs:date('2011-04-07-04:00')                      ]">                 <tr>                     <td>                         <xsl:value-of select="user"/>                     </td>                     <td>                         <xsl:value-of select="time"/>                     </td>                     <td>                         <xsl:value-of select="action"/>                     </td>                 </tr>             </xsl:for-each>         </result>     </xsl:template> </xsl:stylesheet> 

output:

<result>     <tr>         <td>jroderick</td>         <td>2011-04-07t11:41:34.7219171-04:00</td>         <td>check out</td>     </tr>     <tr>         <td>jroderick</td>         <td>2011-04-07t11:41:38.7079901-04:00</td>         <td>check in</td>     </tr>     <tr>         <td>jholby</td>         <td>2011-04-07t14:27:14.0662271-04:00</td>         <td>check in</td>     </tr> </result> 

note: data in xs:datetime format, need cast first this. do take care of time zone


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -