Created
September 23, 2020 21:04
-
-
Save virtual/2d1001b24779daeed4ffc3684dc7fd07 to your computer and use it in GitHub Desktop.
OU Campus Canonical common.xsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <!DOCTYPE xsl:stylesheet [ | |
| <!ENTITY nbsp " "> | |
| <!ENTITY lsaquo "‹"> | |
| <!ENTITY rsaquo "›"> | |
| <!ENTITY laquo "«"> | |
| <!ENTITY raquo "»"> | |
| <!ENTITY copy "©"> | |
| <!ENTITY apos "'"> | |
| <!ENTITY quot """> | |
| <!ENTITY mdash "—"> | |
| <!ENTITY lsquo "‘"> | |
| <!ENTITY middot "·"> | |
| ]> | |
| <!-- | |
| Checks for the following in the PCF: | |
| <ouc:properties label="config"> | |
| <parameter name="canonical" dependency="no" type="filechooser" group="Everyone" prompt="Canonical Link" alt="Canonical link override. Defaults to self."></parameter> | |
| </ouc:properties> | |
| --> | |
| <xsl:stylesheet version="3.0" | |
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
| xmlns:ou="http://omniupdate.com/XSL/Variables" | |
| xmlns:fn="http://omniupdate.com/XSL/Functions" | |
| xmlns:ouc="http://omniupdate.com/XSL/Variables" | |
| exclude-result-prefixes="xsl xs ou fn ouc"> | |
| <xsl:template match="/document"> | |
| <xsl:call-template name="page-directive" /> | |
| <html lang="en"> | |
| <xsl:text disable-output-escaping="yes"><</xsl:text>!--<xsl:text disable-output-escaping="yes"><</xsl:text>![endif]--<xsl:text disable-output-escaping="yes">></xsl:text> | |
| <head> | |
| <xsl:variable name="pageurl" select="concat(string-join(remove(tokenize(substring($ou:httproot, 1), '/'), count(tokenize(substring($ou:httproot, 1), '/'))), '/'),$ou:path)" /> | |
| <script type="text/javascript"> | |
| var page_url="<xsl:value-of select="$pageurl"/>"; | |
| </script> | |
| <xsl:call-template name="header-canonical"> | |
| <xsl:with-param name="pageurl" select="$pageurl"/> | |
| </xsl:call-template> | |
| </head> | |
| <body>...</body> | |
| </html> | |
| <!-- end html --> | |
| </xsl:template> | |
| <xsl:template name="header-canonical"> | |
| <xsl:param name="pageurl"/> | |
| <xsl:choose> | |
| <xsl:when test="not(ou:pcf-param('canonical') = '')"> | |
| <xsl:choose> | |
| <xsl:when test="(starts-with(ou:pcf-param('canonical'), 'http'))"> | |
| <!-- starts with http/s --> | |
| <link rel="canonical" href="{ou:pcf-param('canonical')}"/> | |
| </xsl:when> | |
| <xsl:otherwise> | |
| <link rel="canonical" href="{concat(string-join(remove(tokenize(substring($ou:httproot, 1), '/'), count(tokenize(substring($ou:httproot, 1), '/'))), '/'), ou:pcf-param('canonical'))}"/> | |
| </xsl:otherwise> | |
| </xsl:choose> | |
| </xsl:when> | |
| <xsl:otherwise> | |
| <link rel="canonical" href="{$pageurl}"/> | |
| </xsl:otherwise> | |
| </xsl:choose> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment