-
Notifications
You must be signed in to change notification settings - Fork 2
/
redirect.xsl
84 lines (70 loc) · 2.33 KB
/
redirect.xsl
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xsl:stylesheet>
<!--*
* Create a "redirect" page to automatically redirect the
* brower to the new page
*
* Currently a very simple stylesheet that requires only one
* parameter.
*
* Parameters:
* . filename=full name of output file (including .html)
*
*-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:extfuncs="http://hea-www.harvard.edu/~dburke/xsl/extfuncs"
extension-element-prefixes="extfuncs">
<!--* Change this if the filename changes *-->
<xsl:variable name="hack-import-redirect" select="extfuncs:register-import-dependency('redirect.xsl')"/>
<xsl:output method="text"/>
<xsl:param name="filename"/>
<xsl:template match="/">
<!--*
* safety check: are all the required parameters defined/sensible
*-->
<xsl:if test="$filename=''">
<xsl:message terminate="yes">
Error:
the stylesheet has been called without setting the required parameter
filename
</xsl:message>
</xsl:if>
<xsl:apply-templates name="redirect"/>
</xsl:template> <!--* match=/ *-->
<!--*
* create: <page>.html
*
* the tag has one node - to - which contains the url
* the page is to be redirected to
*
* Currently we always set the delay to 0.
* A value > 0 would be easy to allow, but we'd then have to
* worry about what text to include on the page
*
* The title tag is needed to ensure the page is valid
* ie the DTD requires it. It is not clear what use it
* is beyond ensuring validity.
*-->
<xsl:template match="redirect">
<!--* output filename to stdout *-->
<xsl:value-of select="$filename"/><xsl:text>
</xsl:text>
<!--* create document *-->
<xsl:document href="{$filename}" method="html" media-type="text/html"
doctype-system="about:legacy-compat"
version="5.0">
<!--* create document *-->
<html lang="en-US">
<head>
<!-- <meta charset="UTF-8"/> -->
<title>The page you are looking for has moved</title>
<meta http-equiv="Refresh" >
<xsl:attribute name="content">0; URL=<xsl:value-of select="to"/></xsl:attribute>
</meta>
</head>
<body/>
</html>
</xsl:document>
</xsl:template> <!--* match=redirect *-->
</xsl:stylesheet>