source: BLFS/xsl/process-replaceable.xsl@ 3ac3ae1

ablfs-more legacy trunk
Last change on this file since 3ac3ae1 was 30732c6a, checked in by Pierre Labastie <pierre@…>, 5 years ago

Process layout replaceable

  • Property mode set to 100644
File size: 5.5 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<!-- keyboard layout for the gdm page (as of BLFS 9.0) -->
58 <xsl:param name="xkblayout" select="'us'"/>
59
60<!--===================================================================-->
61<!-- the main template: to be adjusted depending on the book -->
62 <xsl:template match="replaceable">
63 <xsl:choose>
64<!-- When adding a user to a group, the book uses "username" in a replaceable
65 tag. Replace by the user name only if not running as root -->
66 <xsl:when test="contains(string(),'username') and $sudo='y'">
67 <xsl:text>$USER</xsl:text>
68 </xsl:when>
69<!-- The next three entries are for gpm. I guess those settings are OK
70 for a laptop or desktop. -->
71 <xsl:when test="contains(string(),'yourprotocol')">
72 <xsl:text>imps2</xsl:text>
73 </xsl:when>
74 <xsl:when test="contains(string(),'yourdevice')">
75 <xsl:text>/dev/input/mice</xsl:text>
76 </xsl:when>
77 <xsl:when test="contains(string(),'additional options')"/>
78<!-- the book has four fields for language. The language param is
79 broken into four pieces above. We use the results here. -->
80 <xsl:when test="contains(string(),'&lt;ll&gt;')">
81 <xsl:copy-of select="$lang-ll"/>
82 </xsl:when>
83 <xsl:when test="contains(string(),'&lt;CC&gt;')">
84 <xsl:copy-of select="$lang-CC"/>
85 </xsl:when>
86 <xsl:when test="contains(string(),'&lt;charmap&gt;')">
87 <xsl:copy-of select="$lang-charmap"/>
88 </xsl:when>
89 <xsl:when test="contains(string(),'@modifier')">
90 <xsl:copy-of select="$lang-modifier"/>
91 </xsl:when>
92<!-- keyboard layout for X/waylang (only GDM as of BLFS-9.0) -->
93 <xsl:when test="contains(string(),'layout')">
94 <xsl:copy-of select="$xkblayout"/>
95 </xsl:when>
96<!-- At several places, the number of jobs is given as "N" in a replaceable
97 tag. We either detect "N" alone or &lt;N&gt; Replace N with 4. -->
98 <xsl:when test="contains(string(),'&lt;N&gt;') or string()='N'">
99 <xsl:text>4</xsl:text>
100 </xsl:when>
101<!-- Mercurial config file uses user_name. Replace only if non root.
102 Add a bogus mail field. That works for the proposed tests anyway. -->
103 <xsl:when test="contains(string(),'user_name') and $sudo='y'">
104 <xsl:text>$USER ${USER}@mail.bogus</xsl:text>
105 </xsl:when>
106<!-- Use the config for Gtk+3 as is -->
107 <xsl:when test="ancestor::sect1[@id='gtk3']">
108 <xsl:copy-of select="string()"/>
109 </xsl:when>
110<!-- Give 1Gb to fop. Hopefully, nobody has less RAM nowadays. -->
111 <xsl:when test="contains(string(),'RAM_Installed')">
112 <xsl:text>1024</xsl:text>
113 </xsl:when>
114<!-- for MIT-Kerberos config file -->
115 <xsl:when test="string()='&lt;EXAMPLE.ORG&gt;'">
116 <xsl:copy-of select="$DOMAINNAME"/>
117 </xsl:when>
118 <xsl:when test="string()='&lt;example.org&gt;'">
119 <xsl:copy-of select="$domainname"/>
120 </xsl:when>
121 <xsl:when test="string()='&lt;belgarath.example.org&gt;'">
122 <xsl:copy-of select="$fqdn"/>
123 </xsl:when>
124<!-- in this case, even root can be used -->
125 <xsl:when test="string()='&lt;loginname&gt;'">
126 <xsl:text>$USER</xsl:text>
127 </xsl:when>
128 <xsl:otherwise>
129 <xsl:text>**EDITME</xsl:text>
130 <xsl:apply-templates/>
131 <xsl:text>EDITME**</xsl:text>
132 </xsl:otherwise>
133 </xsl:choose>
134 </xsl:template>
135
136 <xsl:template match="replaceable" mode="root">
137 <xsl:apply-templates select="."/>
138 </xsl:template>
139
140</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.