forked from lantanagroup/stylesheets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.xsl
94 lines (94 loc) · 3.7 KB
/
compile.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
85
86
87
88
89
90
91
92
93
94
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs xsl"
version="1.0">
<xsl:output indent="yes" method="xml" />
<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
<xsl:param name="styleFile" select="'Stylesheets/CDA/cda-style.xsl'" />
<xsl:param name="jsFile" select="'Sytlesheets/CDA/cda-js-dependencies.xsl'" />
<xsl:param name="bootstrap-css-cdn" />
<xsl:param name="bootstrap-js-cdn" />
<xsl:param name="jquery-js-cdn" />
<xsl:param name="jquery-ui-js-cdn" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="xsl:stylesheet">
<axsl:stylesheet version="1.0">
<xsl:attribute name="version">1.0</xsl:attribute>
<xsl:apply-templates />
<xsl:apply-templates select="document($styleFile)/xsl:stylesheet/*" />
<xsl:apply-templates select="document($jsFile)/xsl:stylesheet/*"/>
</axsl:stylesheet>
</xsl:template>
<xsl:template match="xsl:template[@name='bootstrap-css']/style">
<xsl:choose>
<xsl:when test="$bootstrap-css-cdn">
<link rel="stylesheet">
<xsl:attribute name="href"><xsl:value-of select="$bootstrap-css-cdn"/></xsl:attribute>
</link>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xsl:template[@name='bootstrap-javascript']/script">
<xsl:choose>
<xsl:when test="$bootstrap-js-cdn">
<script type="text/javascript">
<xsl:attribute name="src"><xsl:value-of select="$bootstrap-js-cdn"/></xsl:attribute>
</script>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xsl:template[@name='jquery']/script">
<xsl:choose>
<xsl:when test="$jquery-js-cdn">
<script type="text/javascript">
<xsl:attribute name="src"><xsl:value-of select="$jquery-js-cdn"/></xsl:attribute>
</script>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xsl:template[@name='jquery-ui']/script">
<xsl:choose>
<xsl:when test="$jquery-ui-js-cdn">
<script type="text/javascript">
<xsl:attribute name="src"><xsl:value-of select="$jquery-ui-js-cdn"/></xsl:attribute>
</script>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xsl:include[@href='cda-style.xsl']">
<!-- Ignore -->
</xsl:template>
<xsl:template match="xsl:include[@href='cda-js-dependencies.xsl']">
<!-- Ignore -->
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>