Skip to content

Commit

Permalink
banner
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Gutteridge committed Feb 2, 2011
1 parent 9c104f4 commit b45be0d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 88 deletions.
7 changes: 3 additions & 4 deletions etc/banner.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ xslt: lib/banner.xsl

# make a 'use' function later?

format: psv
in: var/Banner.courses.out
include: etc/boilerplate.include

format: csv
in: localdata/banner.csv

set: license-uri=http://reference.data.gov.uk/id/open-government-licence
set: base-module-uri=http://id.southampton.ac.uk/module/
set: base-course-uri=http://id.southampton.ac.uk/course/

Expand Down
134 changes: 50 additions & 84 deletions lib/banner.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,107 +7,73 @@
xmlns:gr="http://purl.org/goodrelations/v1#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:spatialrelations="http://data.ordnancesurvey.co.uk/ontology/spatialrelations/"
xmlns:oo="http://purl.org/openorg/">
xmlns:ns="http://id.southampton.ac.uk/ns/"
xmlns:oo="http://purl.org/openorg/"
xmlns:aiiso="http://purl.org/vocab/aiiso/schema#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:dcterms="http://purl.org/dc/terms/"
>

<!-- note to self... use rapper to remove duplicate triples -->

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no" />

<xsl:variable name='base-module-uri' select='/g:grinder-data/g:set[@id="base-module-uri"]' />
<xsl:variable name='base-course-uri' select='/g:grinder-data/g:set[@id="base-course-uri"]' />
<xsl:variable name='license-uri' select='/g:grinder-data/g:set[@id="license-uri"]' />
<xsl:variable name='_timestamp' select='/g:grinder-data/g:set[@id="_timestamp"]' />

<xsl:template match="/g:grinder-data">
<rdf:RDF>

<rdf:Description rdf:about=''>
<xsl:if test="$license-uri != ''">
<dcterms:license rdf:resource="{$license-uri}" />
</xsl:if>
<rdfs:comment>Generated by OpenOrg Grinder using the banner.xsl by Christopher Gutteridge. See http://wiki.openorg.ecs.soton.ac.uk/index.php/OpenOrg_Grinder. Generated at <xsl:value-of select='$_timestamp' /></rdfs:comment>
</rdf:Description>

<xsl:comment>TOP</xsl:comment>
<xsl:apply-templates select="g:row" />
</rdf:RDF>
</xsl:template>

<xsl:template match="g:row">
<!-- 00-69 = 2000-2069, 70-99 = 1970-1999 -->
<xsl:variable name='y1' select='((number(substring( g:COURSE_NAME, 1, 2 ))+30)mod 100)+1970' />
<xsl:variable name='y2' select='((number(substring( g:COURSE_NAME, 4, 2 ))+30)mod 100)+1970' />
<xsl:variable name='module_id' select='substring( g:COURSE_ID, 1, 8 )' />
<xsl:variable name='course_id' select='substring( g:COURSE_ID, 10, 5 )' />

(<xsl:value-of select='$y1' />-<xsl:value-of select='$y2' />)
(<xsl:value-of select='$module_id' />-<xsl:value-of select='$course_id' />)

<rdf:Description rdf:about="{$base-course-uri}{$course_id}/{$y1}-{$y2}">
</rdf:Description>
<!--
<xsl:variable name='uri' select='concat( $base-pos-uri , string(g:Code) )' />
<rdf:Description rdf:about="{$uri}">
<rdf:type rdf:resource="http://purl.org/goodrelations/v1#LocationOfSalesOrServiceProvisioning" />
<xsl:apply-templates />
</rdf:Description>
<xsl:for-each select="*">
<xsl:if test="substring( name(.), 1, 7 ) = 'Offers-'">
<rdf:Description rdf:about="{$base-offers-uri}{substring( name(.), 8 )}">
<rdf:type rdf:resource="http://purl.org/goodrelations/v1#Offering" />
<gr:availableAtOrFrom rdf:resource="{$uri}" />
</rdf:Description>
</xsl:if>
</xsl:for-each>
<row>
<COURSE_ID>XXXX1234-99999-87-88</COURSE_ID>
<EXTERNAL_COURSE_KEY>XXXX1234-2323-87-88</EXTERNAL_COURSE_KEY>
<COURSE_NAME>87-88-Demo Course-2323</COURSE_NAME>
</row>
<csta-code>S</csta-code>
<billing-hours-sum>5</billing-hours-sum>
<gmod-code>G</gmod-code>
<ptrm-start-date>30-Sep-10</ptrm-start-date>
<ptrm-end-date>29-Jan-11</ptrm-end-date>
<attr-code1>NQF7</attr-code1>
<schd-code1>NULL</schd-code1>
<instructor1-full-name>NULL</instructor1-full-name>
-->
</xsl:template>

<xsl:template match="g:Name">
<rdfs:label><xsl:value-of select="string(.)"/></rdfs:label>
</xsl:template>

<xsl:template match="g:Building">
<spatialrelations:within rdf:resource='{$base-building-uri}{string(.)}' />
</xsl:template>
<xsl:template match="g:row">
<aiiso:Module rdf:about="{$base-course-uri}{g:crn-key}/2010-2011">
<rdfs:label><xsl:value-of select="g:subj-code" /><xsl:value-of select="g:crse-number" />: <xsl:value-of select="g:long-title" /> (<xsl:value-of select="g:ptrm-desc" />)</rdfs:label>
<aiiso:name><xsl:value-of select="g:long-title" /></aiiso:name>
<ns:BannerCrnKey><xsl:value-of select="g:crn-key" /></ns:BannerCrnKey>
<ns:BannerCollCode><xsl:value-of select="g:coll-code" /></ns:BannerCollCode>
<ns:BannerLevlCode1><xsl:value-of select="g:levl-code1" /></ns:BannerLevlCode1>
<ns:BannerSubjCode><xsl:value-of select="g:subj-code" /></ns:BannerSubjCode>
<ns:BannerPtrmCode><xsl:value-of select="g:ptrm-code" /></ns:BannerPtrmCode>
<ns:BannerCrseNumber><xsl:value-of select="g:crse-number" /></ns:BannerCrseNumber>
<ns:BannerCreditHoursSum><xsl:value-of select="g:credit-hours-sum" /></ns:BannerCreditHoursSum>
</aiiso:Module>
<ns:ModuleInSyllabus rdf:about="{$base-module-uri}{g:subj-code}{g:crse-number}/2010-2011">
<rdfs:label><xsl:value-of select="g:subj-code" /><xsl:value-of select="g:crse-number" />: <xsl:value-of select="g:long-title" /> (2010-2011 session)</rdfs:label>
<aiiso:name><xsl:value-of select="g:long-title" /></aiiso:name>
<ns:BannerCrnKey><xsl:value-of select="g:crn-key" /></ns:BannerCrnKey>
<ns:BannerCollCode><xsl:value-of select="g:coll-code" /></ns:BannerCollCode>
<ns:BannerLevlCode1><xsl:value-of select="g:levl-code1" /></ns:BannerLevlCode1>
<ns:BannerSubjCode><xsl:value-of select="g:subj-code" /></ns:BannerSubjCode>
<ns:BannerPtrmCode><xsl:value-of select="g:ptrm-code" /></ns:BannerPtrmCode>
<ns:BannerCrseNumber><xsl:value-of select="g:crse-number" /></ns:BannerCrseNumber>
<ns:BannerCreditHoursSum><xsl:value-of select="g:credit-hours-sum" /></ns:BannerCreditHoursSum>
<ns:moduleTaughtAs rdf:resource="{$base-course-uri}{g:crn-key}/2010-2011" />
</ns:ModuleInSyllabus>

<xsl:template match="g:Mon"><xsl:call-template name="open-hours-spec">
<xsl:with-param name="day">Monday</xsl:with-param>
</xsl:call-template></xsl:template>
<xsl:template match="g:Tue"><xsl:call-template name="open-hours-spec">
<xsl:with-param name="day">Tuesday</xsl:with-param>
</xsl:call-template></xsl:template>
<xsl:template match="g:Wed"><xsl:call-template name="open-hours-spec">
<xsl:with-param name="day">Wednesday</xsl:with-param>
</xsl:call-template></xsl:template>
<xsl:template match="g:Thu"><xsl:call-template name="open-hours-spec">
<xsl:with-param name="day">Thursday</xsl:with-param>
</xsl:call-template></xsl:template>
<xsl:template match="g:Fri"><xsl:call-template name="open-hours-spec">
<xsl:with-param name="day">Friday</xsl:with-param>
</xsl:call-template></xsl:template>
<xsl:template match="g:Sat"><xsl:call-template name="open-hours-spec">
<xsl:with-param name="day">Saturday</xsl:with-param>
</xsl:call-template></xsl:template>
<xsl:template match="g:Sun"><xsl:call-template name="open-hours-spec">
<xsl:with-param name="day">Sunday</xsl:with-param>
</xsl:call-template></xsl:template>

<xsl:template name="open-hours-spec">
<xsl:param name="day"/>
<gr:hasOpeningHoursSpecification>
<rdf:Description rdf:about="{$base-pos-uri}{string(../g:Code)}#{$day}-{string(.)}-{$valid-from}">
<rdf:type rdf:resource="http://purl.org/goodrelations/v1#OpeningHoursSpecification" />
<gr:opens rdf:datatype="http://www.w3.org/2001/XMLSchema#time">
<xsl:value-of select="concat( substring(string(.),1,2), ':', substring(string(.),3,2), ':00' )"/>
</gr:opens>
<gr:closes rdf:datatype="http://www.w3.org/2001/XMLSchema#time">
<xsl:value-of select="concat( substring(string(.),6,2), ':', substring(string(.),8,2), ':00' )"/>
</gr:closes>
<gr:hasOpeningHoursDayOfWeek rdf:resource="http://purl.org/goodrelations/v1#{$day}" />
<gr:validFrom rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
<xsl:value-of select="concat( $valid-from, 'T00:00:00', $timezone )" />
</gr:validFrom>
<gr:validThrough rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
<xsl:value-of select="concat( $valid-through, 'T23:59:59', $timezone )" />
</gr:validThrough>
</rdf:Description>
</gr:hasOpeningHoursSpecification>
</xsl:template>

<xsl:template match="*" priority="-1">
Expand Down

0 comments on commit b45be0d

Please sign in to comment.