1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 |
|
---|
3 | <!-- $Id:$ -->
|
---|
4 | <!-- Extracts minimal versions from LFS book host requirements,
|
---|
5 | and generates a script containing statements of the
|
---|
6 | form MIN_prog_VERSION=xx.yy.zz.
|
---|
7 | -->
|
---|
8 |
|
---|
9 | <xsl:stylesheet
|
---|
10 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
11 | version="1.0">
|
---|
12 |
|
---|
13 | <xsl:output method="text"/>
|
---|
14 |
|
---|
15 | <xsl:template match="/sect1">
|
---|
16 | <xsl:apply-templates select=".//listitem//emphasis"/>
|
---|
17 | </xsl:template>
|
---|
18 |
|
---|
19 | <xsl:template match="emphasis">
|
---|
20 | <!-- We assume that what is emphasized is in the form:
|
---|
21 | aa...aa-dccsaaa (a anything except @, - "dash", d digit,
|
---|
22 | c anything except space, s space)
|
---|
23 | or
|
---|
24 | aa...aasdccsaaa
|
---|
25 | This means we have to replace digits with @, and look for '-@'
|
---|
26 | or ' @' -->
|
---|
27 | <xsl:variable name="normalized-string"
|
---|
28 | select="translate(normalize-space(string()),
|
---|
29 | '0123456789',
|
---|
30 | '@@@@@@@@@@')"/>
|
---|
31 | <xsl:variable name="begin-ver">
|
---|
32 | <xsl:choose>
|
---|
33 | <xsl:when test="contains($normalized-string,' @')">
|
---|
34 | <xsl:value-of select="string-length(substring-before($normalized-string,' @'))+1"/>
|
---|
35 | </xsl:when>
|
---|
36 | <xsl:otherwise>
|
---|
37 | <xsl:value-of select="string-length(substring-before($normalized-string,'-@'))+1"/>
|
---|
38 | </xsl:otherwise>
|
---|
39 | </xsl:choose>
|
---|
40 | </xsl:variable>
|
---|
41 |
|
---|
42 | <xsl:variable name="remaining-part"
|
---|
43 | select="substring($normalized-string,number($begin-ver)+1)"/>
|
---|
44 |
|
---|
45 | <xsl:variable name="end-ver">
|
---|
46 | <xsl:choose>
|
---|
47 | <xsl:when test="contains($remaining-part,' ')">
|
---|
48 | <xsl:value-of
|
---|
49 | select="string-length(substring-before($remaining-part,' '))"/>
|
---|
50 | </xsl:when>
|
---|
51 | <xsl:otherwise>
|
---|
52 | <xsl:value-of
|
---|
53 | select="string-length($remaining-part)"/>
|
---|
54 | </xsl:otherwise>
|
---|
55 | </xsl:choose>
|
---|
56 | </xsl:variable>
|
---|
57 |
|
---|
58 | <xsl:text>local MIN_</xsl:text>
|
---|
59 | <xsl:choose>
|
---|
60 | <xsl:when test="contains(string(),'Kernel')">
|
---|
61 | <xsl:text>Linux</xsl:text>
|
---|
62 | </xsl:when>
|
---|
63 | <xsl:when test="contains(string(),'GLIBC')">
|
---|
64 | <xsl:text>Glibc</xsl:text>
|
---|
65 | </xsl:when>
|
---|
66 | <xsl:when test="contains(string(),'XZ')">
|
---|
67 | <xsl:text>Xz</xsl:text>
|
---|
68 | </xsl:when>
|
---|
69 | <xsl:otherwise>
|
---|
70 | <!-- We assume that there are no dash nor space in other names -->
|
---|
71 | <xsl:value-of select="substring(string(),1,number($begin-ver)-1)"/>
|
---|
72 | </xsl:otherwise>
|
---|
73 | </xsl:choose>
|
---|
74 | <xsl:text>_VER=</xsl:text>
|
---|
75 | <xsl:value-of select="substring(string(),number($begin-ver)+1,$end-ver)"/>
|
---|
76 | <xsl:text>
|
---|
77 | </xsl:text>
|
---|
78 | </xsl:template>
|
---|
79 | </xsl:stylesheet>
|
---|