Skip to content.

The E-Learning Framework

Sections
Personal tools
You are here: Home » ELF Project Directory » Course Information Group » AdamSmithFoXsl
Views

AdamSmithFoXsl

XSL transform to create formatting objects for producing a brochure of programmes for Adam Smith College, kindly supplied by Tavis Reddick, Web Developer

Click here to get the file

Size 7.5 kB - File type text/xml

File contents

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xcri="http://elframework.org/curriculum/elements" xmlns:dc="http://purl.org/dc/elements/1.1/">

	<xsl:import href="http://www.adamsmithcollege.ac.uk/xml/xsl/fo/html/text.xsl"/>

	<xsl:output encoding="utf-8" indent="yes" method="xml" version="1.0" exclude-result-prefixes="xs fn xdt xhtml xcri"/>

	<!-- Takes an XCRI 1.0 document and turns specs (programmes) and offerings into a table suitable for a marketing brochure. -->

	<!-- This is intended to be extended to cover multiple groupings (and therefore output tables) within curriculum, hence the for-each curriculum placeholder. -->

	<!-- XCRI (eXchanging Course Related Information) group at: http://www.elframework.org/projects/xcri -->

	<!-- Prototype created 2006-05-09 -->

	<!-- tavisreddick@adamsmith.ac.uk -->

	

	<!-- Set some default parameter values -->

	<xsl:param name="bodyFontSize" select="'12pt'" />

	<xsl:param name="mainBackgroundColor" select="'#FFFFFF'" />

	<xsl:param name="alternateBackgroundColor" select="'#EEEEEE'" />

	<xsl:param name="primaryHighlightColor" select="'#00A0C3'" />

	<xsl:param name="tableCellPadding" select="'0.5mm'" />

	<xsl:template match="/">

		<fo:root font-family="Helvetica" font-size="{$bodyFontSize}" xmlns="http://www.w3.org/1999/XSL/Format">

			<fo:layout-master-set>

				<fo:simple-page-master master-name="BrochureContentA4" margin-bottom="10mm" margin-left="15mm" margin-right="15mm" margin-top="10mm" page-height="297mm" page-width="210mm">

					<fo:region-body column-count="1" margin-top="5mm" margin-bottom="5mm" region-name="SinglePageBody"/>

					<fo:region-before extent="5mm" region-name="ContentHeader"/>

					<fo:region-after extent="10mm" region-name="ContentFooter"/>

				</fo:simple-page-master>

			</fo:layout-master-set>

			<fo:page-sequence master-reference="BrochureContentA4">

				<fo:title>Demo of programme and offering output for Marketing brochure</fo:title>

				<fo:static-content flow-name="ContentHeader" font-size="9pt" border-after-style="solid" border-after-color="{$primaryHighlightColor}" border-after-width="0.2mm">

					<fo:block text-align="right">

						<xsl:value-of select="xcri:curriculum/xcri:organization/dc:title" />

					</fo:block>

				</fo:static-content>

				<fo:static-content flow-name="ContentFooter">

					<fo:block color="{$primaryHighlightColor}" text-align="center" font-size="12pt">

						<fo:page-number/>

					</fo:block>

				</fo:static-content>

				<fo:flow flow-name="SinglePageBody">

					<xsl:for-each select="xcri:curriculum">

						<fo:table border-collapse="separate" space-after.optimum="12pt" table-layout="fixed">

                        <table-column column-width="5cm" background-color="{$alternateBackgroundColor}"/>

                        <table-column column-width="3cm"/>

                        <table-column column-width="2cm" background-color="{$alternateBackgroundColor}"/>

                        <table-column column-width="2cm"/>

                        <table-column column-width="2cm" background-color="{$alternateBackgroundColor}"/>

                        <table-column column-width="2cm"/>

                        <table-column column-width="2cm" background-color="{$alternateBackgroundColor}"/>

							<fo:table-header font-size="8pt" font-weight="bold" color="#00A0C3" background-color="{$mainBackgroundColor}">

								<fo:table-row xsl:use-attribute-sets="tableRowBorder">

									<fo:table-cell>

										<fo:block padding="{$tableCellPadding}">Programme Title</fo:block>

									</fo:table-cell>

									<fo:table-cell>

										<fo:block padding="{$tableCellPadding}">Programme Code</fo:block>

									</fo:table-cell>

									<fo:table-cell>

										<fo:block padding="{$tableCellPadding}">Day</fo:block>

									</fo:table-cell>

									<fo:table-cell>

										<fo:block padding="{$tableCellPadding}">Start</fo:block>

									</fo:table-cell>

									<fo:table-cell>

										<fo:block padding="{$tableCellPadding}">End</fo:block>

									</fo:table-cell>

									<fo:table-cell>

										<fo:block padding="{$tableCellPadding}">Time</fo:block>

									</fo:table-cell>

									<fo:table-cell>

										<fo:block padding="{$tableCellPadding}">Location</fo:block>

									</fo:table-cell>

								</fo:table-row>

							</fo:table-header>

							<fo:table-body font-size="8pt">

								<xsl:for-each select="xcri:spec[@ type='programme']">

									<xsl:variable name="offeringCount" select="count(xcri:offeringPattern/xcri:offerings/xcri:offering)"/>

									<xsl:variable name="rowColour">

										<xsl:choose>

											<xsl:when test="position() mod 2 = 1">

												<xsl:value-of select="$alternateBackgroundColor" />

											</xsl:when>

											<xsl:otherwise>

												<xsl:value-of select="$mainBackgroundColor" />

											</xsl:otherwise>

										</xsl:choose>

									</xsl:variable>

									<xsl:for-each select="xcri:offeringPattern/xcri:offerings/xcri:offering">

										<fo:table-row font-size="8pt" xsl:use-attribute-sets="tableRowBorder" background-color="{$rowColour}">

											<xsl:if test="position()=1">

												<fo:table-cell number-rows-spanned="{$offeringCount}">

													<fo:block padding="{$tableCellPadding}">

														<xsl:value-of select="../../../dc:title"/>

													</fo:block>

												</fo:table-cell>

												<fo:table-cell number-rows-spanned="{$offeringCount}">

													<fo:block padding="{$tableCellPadding}">

														<xsl:value-of select="xcri:code"/>

													</fo:block>

												</fo:table-cell>

											</xsl:if>

											<fo:table-cell>

												<fo:block padding="{$tableCellPadding}">

												<!-- Find XCRI equivalent of day of week. -->

													<xsl:value-of select="dayOfWeek" />

												</fo:block>

											</fo:table-cell>

											<fo:table-cell>

												<fo:block padding="{$tableCellPadding}">

													<xsl:value-of select="xcri:start" />

												</fo:block>

											</fo:table-cell>

											<fo:table-cell>

												<fo:block padding="{$tableCellPadding}">

													<xsl:value-of select="xcri:end" />

												</fo:block>

											</fo:table-cell>

											<fo:table-cell>

												<!-- Find XCRI equivalents of start and end times. -->

												<fo:block padding="{$tableCellPadding}">

													<xsl:value-of select="startTime" />

													<xsl:text> - </xsl:text>

													<xsl:value-of select="endTime" />

												</fo:block>

											</fo:table-cell>

											<fo:table-cell>

												<fo:block padding="{$tableCellPadding}">

													<xsl:value-of select="xcri:location" />

												</fo:block>

											</fo:table-cell>

										</fo:table-row>

									</xsl:for-each>

								</xsl:for-each>

							</fo:table-body>

						</fo:table>

					</xsl:for-each>

				</fo:flow>

			</fo:page-sequence>

		</fo:root>

	</xsl:template>

	<xsl:attribute-set name="tableRowBorder">

		<xsl:attribute name="border-after-color">#00A0C3</xsl:attribute>

		<xsl:attribute name="border-after-style">solid</xsl:attribute>

		<xsl:attribute name="border-after-width">0.2mm</xsl:attribute>

	</xsl:attribute-set>

</xsl:stylesheet>

Created by stubbsy
Last modified 2006-05-12 05:09 PM
Funding Partner
JISC Distributed eLearning Strand
« May 2012 »
Su Mo Tu We Th Fr Sa
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Files and Documents
Implements services
Related ELF services
No files or documents.