source: ccr2ccd-xslt/trunk/make/templates/datetime.xsl@ 1800

Last change on this file since 1800 was 985, checked in by George Lilly, 14 years ago

set up testing environment

File size: 4.1 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:astm-org:CCR" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="a date">
3 <!-- Displays the DateTime. If ExactDateTime is present, it will format according
4 to the 'fmt' variable. The default format is: Oct 31, 2005 -->
5 <xsl:import href="../lib/date.format-date.template.xsl"/>
6 <xsl:template name="dateTime" match="a:DateTime">
7 <xsl:param name="dt" select="."/>
8 <xsl:param name="fmt">MMM dd, yyyy</xsl:param>
9 <xsl:for-each select="$dt">
10 <tr>
11 <xsl:if test="$dt/a:Type/a:Text">
12 <td>
13 <xsl:value-of select="a:Type/a:Text"/>:
14 </td>
15 </xsl:if>
16 <xsl:choose>
17 <xsl:when test="a:ExactDateTime">
18 <td>
19 <xsl:call-template name="date:format-date">
20 <xsl:with-param name="date-time">
21 <xsl:value-of select="a:ExactDateTime"/>
22 </xsl:with-param>
23 <xsl:with-param name="pattern" select="$fmt"/>
24 </xsl:call-template>
25 </td>
26 </xsl:when>
27 <xsl:when test="$dt/a:Age">
28 <td>
29 <xsl:value-of select="$dt/a:Age/a:Value"/>
30 <xsl:text xml:space="preserve"> </xsl:text>
31 <xsl:value-of select="$dt/a:Age/a:Units/a:Unit"/>
32 </td>
33 </xsl:when>
34 <xsl:when test="$dt/a:ApproximateDateTime">
35 <td>
36 <xsl:value-of select="$dt/a:ApproximateDateTime/a:Text"/>
37 </td>
38 </xsl:when>
39 <xsl:when test="$dt/a:DateTimeRange">
40 <td>
41 <xsl:for-each select="$dt/a:DateTimeRange/a:BeginRange">
42 <xsl:choose>
43 <xsl:when test="$dt/a:ExactDateTime">
44 <xsl:call-template name="date:format-date">
45 <xsl:with-param name="date-time">
46 <xsl:value-of select="$dt/a:ExactDateTime"/>
47 </xsl:with-param>
48 <xsl:with-param name="pattern" select="$fmt"/>
49 </xsl:call-template>
50 </xsl:when>
51 <xsl:when test="$dt/a:Age">
52 <xsl:value-of select="$dt/a:Age/a:Value"/>
53 <xsl:text xml:space="preserve"> </xsl:text>
54 <xsl:value-of select="$dt/a:Age/a:Units/a:Unit"/>
55 </xsl:when>
56 <xsl:when test="$dt/a:ApproximateDateTime">
57 <xsl:value-of select="$dt/a:ApproximateDateTime/a:Text"/>
58 </xsl:when>
59 <xsl:otherwise/>
60 </xsl:choose>
61 </xsl:for-each><xsl:text xml:space="preserve"> </xsl:text>
62 -<xsl:text xml:space="preserve"> </xsl:text>
63 <xsl:for-each select="$dt/a:DateTimeRange/a:EndRange">
64 <xsl:choose>
65 <xsl:when test="$dt/a:ExactDateTime">
66 <xsl:call-template name="date:format-date">
67 <xsl:with-param name="date-time">
68 <xsl:value-of select="$dt/a:ExactDateTime"/>
69 </xsl:with-param>
70 <xsl:with-param name="pattern" select="$fmt"/>
71 </xsl:call-template>
72 </xsl:when>
73 <xsl:when test="$dt/a:Age">
74 <xsl:value-of select="$dt/a:Age/a:Value"/>
75 <xsl:text xml:space="preserve"> </xsl:text>
76 <xsl:value-of select="$dt/a:Age/a:Units/a:Unit"/>
77 </xsl:when>
78 <xsl:when test="$dt/a:ApproximateDateTime">
79 <xsl:value-of select="$dt/a:ApproximateDateTime/a:Text"/>
80 </xsl:when>
81 <xsl:otherwise/>
82 </xsl:choose>
83 </xsl:for-each>
84 </td>
85 </xsl:when>
86 <xsl:otherwise/>
87 </xsl:choose>
88 </tr>
89 </xsl:for-each>
90 </xsl:template>
91</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.