-
Notifications
You must be signed in to change notification settings - Fork 2
/
postprod.xsl
49 lines (43 loc) · 1.73 KB
/
postprod.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
<!--
postprod.xsl: “Post-production” transformations to an HTML page to make it
more suitable for service over the Internet.
⚠ Elements, attribute names, and values that are case-insensitive in HTML
are expected to always be in _lowercase_ in the source document.
-->
<stylesheet version="2.0" xmlns="http://www.w3.org/1999/XSL/Transform">
<output method="html" html-version="5" encoding="utf-8" indent="no"/>
<!-- Embed local CSS files. -->
<param name="basecssuri"/>
<template match="link[@rel='stylesheet'][not(matches(@href, '^\s*[a-z\-]+:'))]">
<element name="style" namespace="">
<value-of select="unparsed-text(resolve-uri(@href, $basecssuri), 'utf-8')"/>
</element>
</template>
<!-- Embed local JS files. -->
<param name="basejsuri"/>
<template match="script[@src][not(matches(@src, '^\s*[a-z\-]+:'))]">
<element name="script" namespace="">
<value-of select="unparsed-text(resolve-uri(@src, $basejsuri), 'utf-8')"/>
</element>
</template>
<!-- Absolutize the required/recommended URLs. -->
<param name="siteorigin"/>
<template match="link[tokenize(@rel) = 'canonical']/@href |
meta[tokenize(@property) = ('og:url', 'og:image')]/@content">
<attribute name="{name()}">
<value-of select="resolve-uri(., $siteorigin)"/>
</attribute>
</template>
<!-- Canonicalize the URL of homepage links. -->
<template match="@href[. = 'index.html']">
<attribute name="href">
<value-of select="'/'"/>
</attribute>
</template>
<!-- Identity transform (verbatim-copy things not matched by previous templates). -->
<template match="node() | @*">
<copy>
<apply-templates select="node() | @*"/>
</copy>
</template>
</stylesheet>