source: common/urls.xsl@ ebf8265

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since ebf8265 was ebf8265, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Added a stylesheet to create a file with download URLs from {C,H}LFS books.

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[ebf8265]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 <xsl:output method="text"/>
7
8 <!-- The FTP server used as fallback -->
9 <xsl:param name="server">ftp://ftp.osuosl.org</xsl:param>
10
11 <!-- The libc model used for HLFS -->
12 <xsl:param name="model" select="glibc"/>
13
14 <xsl:template match="/">
15 <xsl:apply-templates select="//ulink"/>
16 </xsl:template>
17
18 <xsl:template match="ulink">
19 <!-- If some package don't have the predefined strings in their
20 name, the next test must be fixed to match it also. Skip possible
21 duplicated URLs due that may be splitted for PDF output -->
22 <xsl:if test="(ancestor::varlistentry[@condition=$model]
23 or not(ancestor::varlistentry[@condition])) and
24 (contains(@url, '.tar.') or contains(@url, '.tgz')
25 or contains(@url, '.patch')) and
26 not(ancestor-or-self::*/@condition = 'pdf')">
27 <!-- Extract the package name -->
28 <xsl:variable name="package">
29 <xsl:call-template name="package.name">
30 <xsl:with-param name="url" select="@url"/>
31 </xsl:call-template>
32 </xsl:variable>
33 <!-- Extract the directory for that package -->
34 <xsl:variable name="cut"
35 select="translate(substring-after($package, '-'),
36 '0123456789', '0000000000')"/>
37 <xsl:variable name="package2">
38 <xsl:value-of select="substring-before($package, '-')"/>
39 <xsl:text>-</xsl:text>
40 <xsl:value-of select="$cut"/>
41 </xsl:variable>
42 <xsl:variable name="dirname" select="substring-before($package2, '-0')"/>
43 <!-- Write the upstream URLs, except the redirected ones -->
44 <xsl:if test="not(contains(@url,'?'))">
45 <xsl:value-of select="@url"/>
46 </xsl:if>
47 <!-- Using a tab character as fields separator -->
48 <xsl:text> </xsl:text>
49 <xsl:value-of select="$server"/>
50 <xsl:text>/pub/lfs/conglomeration/</xsl:text>
51 <xsl:choose>
52 <!-- TCL don't conform the standard package naming -->
53 <xsl:when test="contains($package, 'tcl')">
54 <xsl:text>tcl/</xsl:text>
55 </xsl:when>
56 <!-- Fix bash-doc directory -->
57 <xsl:when test="contains($package, 'bash-doc')">
58 <xsl:text>bash/</xsl:text>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:value-of select="$dirname"/>
62 <xsl:text>/</xsl:text>
63 </xsl:otherwise>
64 </xsl:choose>
65 <xsl:value-of select="$package"/>
66 <xsl:text>&#x0a;</xsl:text>
67 </xsl:if>
68 </xsl:template>
69
70 <xsl:template name="package.name">
71 <xsl:param name="url"/>
72 <xsl:choose>
73 <xsl:when test="contains($url, '/')">
74 <xsl:call-template name="package.name">
75 <xsl:with-param name="url" select="substring-after($url, '/')"/>
76 </xsl:call-template>
77 </xsl:when>
78 <xsl:otherwise>
79 <xsl:choose>
80 <xsl:when test="contains($url, '?')">
81 <xsl:value-of select="substring-before($url, '?')"/>
82 </xsl:when>
83 <xsl:otherwise>
84 <xsl:value-of select="$url"/>
85 </xsl:otherwise>
86 </xsl:choose>
87 </xsl:otherwise>
88 </xsl:choose>
89 </xsl:template>
90
91</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.