GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
1
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
Handbook
Browse code
Added initial XML template
master
1 parent
ad884fb
commit
847c070c77f9c165afc3d0548ed9dd7153a7ae8f
Nigel Stanger
authored
on 6 Dec 2019
Patch
Showing
1 changed file
calendar/teachingdates/templates/paper-calendar-dates.xml.j2
Ignore Space
Show notes
View
calendar/teachingdates/templates/paper-calendar-dates.xml.j2
0 → 100644
{% macro _shared_parameters() %} <xsl:with-param name="period"> <xsl:choose> <xsl:when test="{$period_condition}"> <xsl:value-of select="@period" /> </xsl:when> <!-- This also covers the case of @period being undefined. --> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Attribute "period" must be one of the values {$period_list}.</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:with-param> <xsl:with-param name="week"> <xsl:value-of select="@week" /> <xsl:if test="not( @week )"> <xsl:message terminate="yes"> <xsl:text>The "week" attribute is required.</xsl:text> </xsl:message> </xsl:if> </xsl:with-param> {%- endmacro -%} <?xml version="1.0" encoding="utf-8"?> <!-- AUTOMATICALLY GENERATED ---DO NOT EDIT! This is automatically generated by ../generate_calendar_dates.php! Elements and templates for generating teaching period dates. Apart from the wrapper templates, this essentially boils down to a giant parameterised lookup table, which is generated by a script. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Generate a date for a given teaching week in a teaching period, in the specified format. Return the date of the Monday of the week, plus an optional signed offset. @period: The teaching period for which to generate the date. [required] @week: The number of the week in the specified teaching period. [required] @format: How to format the date. 'day+long-name' => [FNn] [D] [MNn] (e.g., Friday 10 August) 'day+short-name' => [FNn,*-3] [D] [MNn] (e.g., Fri 10 August) 'day' => [D] [MNn] (e.g., 10 August) 'day-short' => [D] [MNn,*-3] (e.g., 10 Aug) 'day+year' => [D] [MNn], [Y] (e.g., 10 August, 2013) 'day-short+year' => [D] [MNn,*-3], [Y] (e.g., 10 Aug, 2013) 'ISO' => [Y0001]-[M01]-[D01] (e.g., 2012-08-10) date picture string => Any valid XSLT date picture specification (see http://www.w3.org/TR/xslt20/#date-picture-string). @offset: A signed offset specified as an XSLT duration, e.g., "P1D" for plus one day, "-P4D" for minus four days. --> <template name="TeachingPeriodDate" match="TeachingPeriodDate"> <common> <xsl:call-template name="format-teaching-date">{{ _shared_parameters() }} <xsl:with-param name="format"> <xsl:choose> <!-- Named date formats. --> <xsl:when test="@format = 'day+long-name'"> <xsl:text>[FNn] [D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day+short-name'"> <xsl:text>[FNn,*-3] [D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day'"> <xsl:text>[D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day-short'"> <xsl:text>[D] [MNn,*-3]</xsl:text> </xsl:when> <xsl:when test="@format = 'day+year'"> <xsl:text>[D] [MNn], [Y]</xsl:text> </xsl:when> <xsl:when test="@format = 'day-short+year'"> <xsl:text>[D] [MNn,*-3], [Y]</xsl:text> </xsl:when> <xsl:when test="@format = 'ISO'"> <xsl:text>[Y0001]-[M01]-[D01]</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="@format" /> </xsl:otherwise> </xsl:choose> <xsl:if test="not( @format )"> <xsl:text>[Y0001]-[M01]-[D01]</xsl:text> </xsl:if> </xsl:with-param> <xsl:with-param name="offset"> <xsl:value-of select="@offset" /> <xsl:if test="not( @offset )"> <xsl:text>P0D</xsl:text> </xsl:if> </xsl:with-param> </xsl:call-template> </common> </template> <!-- Generate a date range corresponding to a given teaching week in a teaching period (i.e., Monday to Friday). @period: The teaching period for which to generate the date. [required] @week: The number of the week in the specified teaching period. [required] @format: How to format the month name in the date range. 'long' => Output the full month name (e.g., August) 'short' => Output only the first three characters of the month name (e.g., Aug) @wrap: Whether to wrap the date range across two lines (usually for insertion into a narrow cell in a calendar table). 'true' [default] 'false' --> <template name="TeachingPeriodDateRange" match="TeachingPeriodDateRange"> <common> <xsl:call-template name="format-teaching-date-range">{{ _shared_parameters() }} <xsl:with-param name="month-format"> <xsl:choose> <xsl:when test="@format = 'long'"> <xsl:text>[MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'short'"> <xsl:text>[MNn,*-3]</xsl:text> </xsl:when> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Attribute "format" must be either "long" or "short", not "</xsl:text> <xsl:value-of select="@format" /> <xsl:text>".</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:with-param> <!-- Convert @wrap into a boolean value. --> <xsl:with-param name="wrap"> <xsl:value-of select="@wrap = 'yes'" /> </xsl:with-param> </xsl:call-template> </common> </template> {# generated templates go here #} </stylesheet>
Show line notes below