<?xml version="1.0" encoding="utf-8"?> <!-- Elements, etc., that are specific to Otago. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Format a University paper code. These normally appear in the form "SPOD 123", i.e., a space between the subject code and the paper number. --> <template name="paper" match="paper"> <common> <xsl:apply-templates select="subject-code" /> <xsl:text> </xsl:text> <xsl:apply-templates select="paper-number" /> </common> </template> <template name="subject-code" match="paper/subject-code"> <common><xsl:apply-templates /></common> </template> <template name="paper-number" match="paper/paper-number"> <common><xsl:apply-templates /></common> </template> <!-- Generate a hyperlink to a file on Blackboard according to the current paper. It takes a path of the form "foo/bar/baz.html" and adds an appropriate URL prefix. For example, given the paper INFO214 offered in S1 2016, we get https://blackboard.otago.ac.nz/bbcswebdav/courses/INFO214_S1DNI_2016/foo/bar/baz.html. We use the trick of constructing a hyperlink element in a variable from the original BlackboardPath element, copying across all attributes except @path, and constructing a new @url element as appropriate. We can then just apply-templates on the variable. The paper identifier in the output URL is constructed from the global stylesheet variables $subject-code, $paper-number, $period-code, and $paper-year. The "DNI" is hard-coded (naughty!) for now, as that applies to all the papers we offer anyway. @path: The path to the file within Blackboard's file system. @label: The name of the anchor to link to in the URL (i.e., url#label). [optional] @target: The target of the URL (e.g., _blank). Only relevant to (X)HTML. [optional] --> <template name="BlackboardPath" match="BlackboardPath"> <common> <xsl:variable name="hyperlink-node"> <xsl:element name="hyperlink"> <xsl:copy-of select="@*[not(name()='path')]" /> <xsl:attribute name="url"> <xsl:text>https://blackboard.otago.ac.nz/bbcswebdav/courses/</xsl:text> <xsl:value-of select="$subject-code" /> <xsl:value-of select="$paper-number" /> <xsl:text>_</xsl:text> <xsl:value-of select="$period-code" /> <xsl:text>DNI_</xsl:text> <xsl:value-of select="$paper-year" /> <xsl:text>/</xsl:text> <xsl:value-of select="@path" /> </xsl:attribute> <xsl:copy-of select="node()" /> </xsl:element> </xsl:variable> <xsl:apply-templates select="$hyperlink-node" /> </common> </template> <!-- Expand an Otago period code (e.g., "S1") into it's full equivalent (e.g., "First Semester"). $period-code: The period code to be expanded. Returns: The expanded period string. --> <function name="infosci:expand-period-code" as="xs:string"> <common> <xsl:param name="period-code" /> <xsl:variable name="period-string"> <xsl:choose> <xsl:when test="$period-code eq 'SS'"> <xsl:text>Summer School</xsl:text> </xsl:when> <xsl:when test="$period-code eq 'S1'"> <xsl:text>First Semester</xsl:text> </xsl:when> <xsl:when test="$period-code eq 'S2'"> <xsl:text>Second Semester</xsl:text> </xsl:when> <xsl:when test="$period-code eq 'FY'"> <xsl:text>Full Year</xsl:text> </xsl:when> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Unrecognised period code "</xsl:text> <xsl:value-of select="$period-code" /> <xsl:text>".</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:sequence select="$period-string" /> </common> </function> </stylesheet>