source: BLFS/xsl/dependencies.xsl@ 7735c7a

2.4 ablfs-more legacy new_features trunk
Last change on this file since 7735c7a was 7735c7a, checked in by Pierre Labastie <pierre@…>, 10 years ago

Suppress dependency on the preceding page in X chapter

  • Property mode set to 100644
File size: 6.1 KB
Line 
1<?xml version="1.0"?>
2
3<!-- $Id: dependencies.xsl 24 2012-02-16 15:26:15Z labastie $ -->
4
5<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 version="1.0">
7
8 <xsl:output method="text"/>
9
10 <xsl:param name="MTA" select="'sendmail'"/>
11 <xsl:param name="dependencies" select="2"/>
12 <xsl:param name="idofdep" select="'dbus'"/>
13
14 <xsl:key name="depnode"
15 match="package|module"
16 use="name"/>
17
18 <xsl:template match="/">
19 <xsl:apply-templates select="key('depnode',$idofdep)"/>
20 </xsl:template>
21
22 <xsl:template match="package">
23 <xsl:apply-templates select="./dependency[@status='required']"/>
24 <xsl:if test="$dependencies &gt; '1'">
25 <xsl:apply-templates select="./dependency[@status='recommended']"/>
26 <xsl:if test="$dependencies = '3'">
27 <xsl:apply-templates select="./dependency[@status='optional']"/>
28 </xsl:if>
29 </xsl:if>
30 </xsl:template>
31
32 <xsl:template match="module">
33 <xsl:apply-templates select="./dependency[@status='required']"/>
34 <xsl:if test="$dependencies &gt; '1'">
35 <xsl:apply-templates select="./dependency[@status='recommended']"/>
36 <xsl:if test="$dependencies = '3'">
37 <xsl:apply-templates select="./dependency[@status='optional']"/>
38 </xsl:if>
39 </xsl:if>
40 </xsl:template>
41
42 <xsl:template match="dependency">
43 <xsl:variable name="depname">
44 <xsl:choose>
45 <xsl:when test="@name='xorg-env'"/>
46 <xsl:when test="@name='x-window-system'">xinit</xsl:when>
47 <xsl:when test="@name='xorg7'">xinit</xsl:when>
48 <xsl:when test="@name='server-mail'">
49 <xsl:value-of select="$MTA"/>
50 </xsl:when>
51 <xsl:otherwise>
52 <xsl:value-of select="@name"/>
53 </xsl:otherwise>
54 </xsl:choose>
55 </xsl:variable>
56 <xsl:variable name="install_it">
57 <xsl:choose>
58 <xsl:when test="@type='link'">
59<!-- No way to track versions: install ! -->
60 1
61 </xsl:when>
62 <xsl:otherwise>
63 <xsl:call-template name="compare-versions">
64 <xsl:with-param name="version" select="key('depnode',$depname)/version"/>
65 <xsl:with-param name="inst-version" select="key('depnode',$depname)/inst-version"/>
66 </xsl:call-template>
67 </xsl:otherwise>
68 </xsl:choose>
69 </xsl:variable>
70 <xsl:apply-templates select="dependency"/>
71 <xsl:if test="number($install_it)">
72 <xsl:value-of select="$depname"/>
73 <xsl:text>&#xA;</xsl:text>
74 </xsl:if>
75 </xsl:template>
76
77<!-- lexicographic Comparison of strings. There is no way to directly
78 compare strings in XPath. So find the position of the character
79 in the following string. On the other hand, for numeric form style
80 xx.yy.zz, we have to compare xx and x'x', which is not always
81 lexicographic: think of 2.2 vs 2.10 -->
82
83 <xsl:variable name="char-table" select="' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
84 <xsl:variable name= "dot-table" select="'.....................................................'"/>
85
86 <xsl:template name="compare-versions">
87<!-- returns non-zero if version is greater than inst-version -->
88 <xsl:param name="version"/>
89 <xsl:param name="inst-version"/>
90<!-- first make all separators (-_) into dots -->
91 <xsl:variable name="mod-ver" select="translate($version,'-_','..')"/>
92 <xsl:variable name="mod-inst-ver" select="translate($inst-version,'-_','..')"/>
93<!-- Then let us find the position of the first chars in char-table (0 if numeric or dot) -->
94 <xsl:variable name="pos-ver" select="string-length(substring-before($char-table,substring($version,1,1)))"/>
95 <xsl:variable name="pos-inst-ver" select="string-length(substring-before($char-table,substring($inst-version,1,1)))"/>
96 <xsl:choose>
97 <xsl:when test="string-length($inst-version)=0">
98 <xsl:value-of select="string-length($version)"/>
99 </xsl:when>
100 <xsl:when test="string-length($version)=0">
101 0
102 </xsl:when>
103 <xsl:when test="$pos-ver != 0">
104 <xsl:choose>
105 <xsl:when test="$pos-ver = $pos-inst-ver">
106 <xsl:call-template name="compare-versions">
107 <xsl:with-param name="version" select="substring($version,2)"/>
108 <xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
109 </xsl:call-template>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:copy-of select="number($pos-ver &gt; $pos-inst-ver)"/>
113 </xsl:otherwise>
114 </xsl:choose>
115 </xsl:when>
116 <xsl:when test="substring($mod-ver,1,1)='.'">
117 <xsl:choose>
118 <xsl:when test="substring($mod-inst-ver,1,1)='.'">
119 <xsl:call-template name="compare-versions">
120 <xsl:with-param name="version" select="substring($version,2)"/>
121 <xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
122 </xsl:call-template>
123 </xsl:when>
124 <xsl:otherwise>
125 0
126 </xsl:otherwise>
127 </xsl:choose>
128 </xsl:when>
129 <xsl:otherwise>
130 <xsl:choose>
131 <xsl:when test="$pos-inst-ver &gt; 0 or substring($mod-inst-ver,1,1)='.'">
132<!-- do not know what to do: do not install -->
133 0
134 </xsl:when>
135 <xsl:otherwise>
136 <xsl:variable name="tok" select="substring-before(concat(translate($mod-ver,$char-table,$dot-table),'.'),'.')"/>
137 <xsl:variable name="inst-tok" select="substring-before(concat(translate($mod-inst-ver,$char-table,$dot-table),'.'),'.')"/>
138 <xsl:choose>
139 <xsl:when test="number($tok)=number($inst-tok)">
140 <xsl:call-template name="compare-versions">
141 <xsl:with-param name="version" select="substring($version,string-length($tok)+1)"/>
142 <xsl:with-param name="inst-version" select="substring($inst-version,string-length($inst-tok)+1)"/>
143 </xsl:call-template>
144 </xsl:when>
145 <xsl:otherwise>
146 <xsl:copy-of select="number(number($tok) &gt; number($inst-tok))"/>
147 </xsl:otherwise>
148 </xsl:choose>
149 </xsl:otherwise>
150 </xsl:choose>
151 </xsl:otherwise>
152 </xsl:choose>
153 </xsl:template>
154
155</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.