source: BLFS/xsl/process-replaceable.xsl@ 0a0b609

ablfs-more legacy trunk
Last change on this file since 0a0b609 was 96d7e44, checked in by Pierre Labastie <pierre@…>, 5 years ago

BLFS/xsl: move the template for replaceable tags out of the main stylesheet,
and allow replacing some hostname/domainname replaceable tags

  • Property mode set to 100644
File size: 5.1 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version="1.0">
5
6<!-- $Id$ -->
7
8<!--===================================================================-->
9 <!-- Localization in the form ll_CC.charmap@modifier (to be used in
10 bash shell startup scripts). ll, CC, and charmap must be present:
11 no way to use "C" or "POSIX". -->
12 <xsl:param name="language" select="'en_US.UTF-8'"/>
13
14 <!-- Break it in pieces -->
15 <xsl:variable name="lang-ll">
16 <xsl:copy-of select="substring-before($language,'_')"/>
17 </xsl:variable>
18 <xsl:variable name="lang-CC">
19 <xsl:copy-of
20 select="substring-before(substring-after($language,'_'),'.')"/>
21 </xsl:variable>
22 <xsl:variable name="lang-charmap">
23 <xsl:choose>
24 <xsl:when test="contains($language,'@')">
25 <xsl:copy-of
26 select="substring-before(substring-after($language,'.'),'@')"/>
27 </xsl:when>
28 <xsl:otherwise>
29 <xsl:copy-of select="substring-after($language,'.')"/>
30 </xsl:otherwise>
31 </xsl:choose>
32 </xsl:variable>
33 <xsl:variable name="lang-modifier">
34 <xsl:choose>
35 <xsl:when test="contains($language,'@')">
36 <xsl:copy-of select="concat('@',substring-after($language,'@'))"/>
37 </xsl:when>
38 <xsl:otherwise>
39 <xsl:copy-of select="''"/>
40 </xsl:otherwise>
41 </xsl:choose>
42 </xsl:variable>
43<!-- end of language variables -->
44
45<!--===================================================================-->
46<!-- to be used at places where we need the domain- or host- name -->
47 <xsl:param name="fqdn" select="'belgarath.example.org'"/>
48
49<!-- make various useful variables -->
50 <xsl:variable name="hostname" select="substring-before($fqdn,'.')"/>
51 <xsl:variable name="domainname" select="substring-after($fqdn,'.')"/>
52 <xsl:variable name="DOMAINNAME" select="translate($domainname,
53 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
54<!-- end of host/domain name variables -->
55
56<!--===================================================================-->
57<!-- the main template: to be adjusted depending on the book -->
58 <xsl:template match="replaceable">
59 <xsl:choose>
60<!-- When adding a user to a group, the book uses "username" in a replaceable
61 tag. Replace by the user name only if not running as root -->
62 <xsl:when test="contains(string(),'username') and $sudo='y'">
63 <xsl:text>$USER</xsl:text>
64 </xsl:when>
65<!-- The next three entries are for gpm. I guess those settings are OK
66 for a laptop or desktop. -->
67 <xsl:when test="contains(string(),'yourprotocol')">
68 <xsl:text>imps2</xsl:text>
69 </xsl:when>
70 <xsl:when test="contains(string(),'yourdevice')">
71 <xsl:text>/dev/input/mice</xsl:text>
72 </xsl:when>
73 <xsl:when test="contains(string(),'additional options')"/>
74<!-- the book has four fields for language. The language param is
75 broken into four pieces above. We use the results here. -->
76 <xsl:when test="contains(string(),'&lt;ll&gt;')">
77 <xsl:copy-of select="$lang-ll"/>
78 </xsl:when>
79 <xsl:when test="contains(string(),'&lt;CC&gt;')">
80 <xsl:copy-of select="$lang-CC"/>
81 </xsl:when>
82 <xsl:when test="contains(string(),'&lt;charmap&gt;')">
83 <xsl:copy-of select="$lang-charmap"/>
84 </xsl:when>
85 <xsl:when test="contains(string(),'@modifier')">
86 <xsl:copy-of select="$lang-modifier"/>
87 </xsl:when>
88<!-- At several places, the number of jobs is given as "N" in a replaceable
89 tag. We either detect "N" alone or &lt;N&gt; Replace N with 4. -->
90 <xsl:when test="contains(string(),'&lt;N&gt;') or string()='N'">
91 <xsl:text>4</xsl:text>
92 </xsl:when>
93<!-- Mercurial config file uses user_name. Replace only if non root.
94 Add a bogus mail field. That works for the proposed tests anyway. -->
95 <xsl:when test="contains(string(),'user_name') and $sudo='y'">
96 <xsl:text>$USER ${USER}@mail.bogus</xsl:text>
97 </xsl:when>
98<!-- Use the config for Gtk+3 as is -->
99 <xsl:when test="ancestor::sect1[@id='gtk3']">
100 <xsl:copy-of select="string()"/>
101 </xsl:when>
102<!-- Give 1Gb to fop. Hopefully, nobody has less RAM nowadays. -->
103 <xsl:when test="contains(string(),'RAM_Installed')">
104 <xsl:text>1024</xsl:text>
105 </xsl:when>
106<!-- for MIT-Kerberos config file -->
107 <xsl:when test="string()='&lt;EXAMPLE.ORG&gt;'">
108 <xsl:copy-of select="$DOMAINNAME"/>
109 </xsl:when>
110 <xsl:when test="string()='&lt;example.org&gt;'">
111 <xsl:copy-of select="$domainname"/>
112 </xsl:when>
113 <xsl:when test="string()='&lt;belgarath.example.org&gt;'">
114 <xsl:copy-of select="$fqdn"/>
115 </xsl:when>
116<!-- in this case, even root can be used -->
117 <xsl:when test="string()='&lt;loginname&gt;'">
118 <xsl:text>$USER</xsl:text>
119 </xsl:when>
120 <xsl:otherwise>
121 <xsl:text>**EDITME</xsl:text>
122 <xsl:apply-templates/>
123 <xsl:text>EDITME**</xsl:text>
124 </xsl:otherwise>
125 </xsl:choose>
126 </xsl:template>
127
128 <xsl:template match="replaceable" mode="root">
129 <xsl:apply-templates select="."/>
130 </xsl:template>
131
132</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.