[4fe47e3] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
| 3 | xmlns:c="http://schema.cross-lfs.org/book" |
---|
| 4 | version="1.0"> |
---|
| 5 | |
---|
| 6 | <!-- Declare our output type --> |
---|
| 7 | <xsl:output method="xml" |
---|
| 8 | indent="no" |
---|
| 9 | omit-xml-declaration="no" |
---|
| 10 | encoding="utf-8" |
---|
| 11 | doctype-public="-//OASIS//DTD DocBook XML V4.5//EN" |
---|
| 12 | doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" /> |
---|
| 13 | |
---|
| 14 | <xsl:param name="clfs.arch" select="''" /> |
---|
| 15 | <xsl:param name="clfs.multilib" select="''" /> |
---|
[4a39252] | 16 | |
---|
[4fe47e3] | 17 | <!-- Apply the other templates --> |
---|
| 18 | <xsl:template match="@*|node()" priority="-1"> |
---|
| 19 | <xsl:copy> |
---|
| 20 | <xsl:apply-templates select="@*|node()" /> |
---|
| 21 | </xsl:copy> |
---|
| 22 | </xsl:template> |
---|
| 23 | |
---|
[4a39252] | 24 | <!-- Build the package xml --> |
---|
[4fe47e3] | 25 | <xsl:template match="//c:package"> |
---|
| 26 | <xsl:param name="id" select="@id" /> |
---|
| 27 | <xsl:param name="multibuild" select="@c:multibuild" /> |
---|
| 28 | <xsl:call-template name="package-iterator"> |
---|
| 29 | <xsl:with-param name="id" select="$id" /> |
---|
| 30 | <xsl:with-param name="multibuild" select="$multibuild" /> |
---|
| 31 | <xsl:with-param name="bits" select="$clfs.multilib" /> |
---|
| 32 | </xsl:call-template> |
---|
| 33 | </xsl:template> |
---|
| 34 | |
---|
| 35 | <xsl:template name="package-iterator"> |
---|
| 36 | <xsl:param name="id" /> <!-- Base ID of the resulting package --> |
---|
| 37 | <xsl:param name="multibuild" /> <!-- Do we need to install for each bitsize? --> |
---|
| 38 | <xsl:param name="bits" /> <!-- Which bit sizes to create a package for --> |
---|
| 39 | |
---|
[5171adc] | 40 | <xsl:variable name="currentbits" select="substring-before(concat($bits, ','), ',')" /> |
---|
| 41 | <xsl:variable name="remainingbits" select="substring-after($bits, ',')" /> |
---|
| 42 | |
---|
| 43 | <xsl:if test="not(boolean($remainingbits) and $multibuild = 'false')"> |
---|
| 44 | <xsl:call-template name="package-stub"> |
---|
| 45 | <xsl:with-param name="id" select="$id" /> |
---|
| 46 | <xsl:with-param name="idsuffix"> |
---|
| 47 | <xsl:if test="$remainingbits"> |
---|
| 48 | <xsl:value-of select="concat('-', $currentbits)" /> |
---|
| 49 | </xsl:if> |
---|
| 50 | </xsl:with-param> |
---|
| 51 | <xsl:with-param name="bits" select="substring-before(concat($bits, ','), ',')" /> |
---|
[33cb2bd] | 52 | <xsl:with-param name="multibuild" select="$multibuild" /> |
---|
[5171adc] | 53 | </xsl:call-template> |
---|
| 54 | </xsl:if> |
---|
| 55 | |
---|
| 56 | <xsl:if test="$remainingbits"> |
---|
| 57 | <xsl:text> |
---|
| 58 | |
---|
| 59 | </xsl:text> |
---|
| 60 | <xsl:call-template name="package-iterator"> |
---|
| 61 | <xsl:with-param name="id" select="$id" /> |
---|
| 62 | <xsl:with-param name="multibuild" select="$multibuild" /> |
---|
| 63 | <xsl:with-param name="bits" select="$remainingbits" /> |
---|
| 64 | </xsl:call-template> |
---|
| 65 | </xsl:if> |
---|
| 66 | |
---|
[4fe47e3] | 67 | </xsl:template> |
---|
| 68 | |
---|
| 69 | <xsl:template name="package-stub"> |
---|
| 70 | <xsl:param name="id" /> <!-- Base ID of the resulting package --> |
---|
| 71 | <xsl:param name="idsuffix" /> <!-- Suffix to attach to the end of the ID for this perticular instance --> |
---|
| 72 | <xsl:param name="bits" /> <!-- Which bit sizes to create a package for --> |
---|
[33cb2bd] | 73 | <xsl:param name="multibuild" /> <!-- Are there multiple instances of this package? --> |
---|
[4fe47e3] | 74 | |
---|
| 75 | <xsl:for-each select="sect1"> |
---|
[33cb2bd] | 76 | |
---|
[4fe47e3] | 77 | <xsl:copy> |
---|
[33cb2bd] | 78 | |
---|
[4fe47e3] | 79 | <xsl:attribute name="id"> |
---|
| 80 | <xsl:value-of select="concat($id, $idsuffix)" /> |
---|
| 81 | </xsl:attribute> |
---|
[33cb2bd] | 82 | |
---|
[4fe47e3] | 83 | <xsl:processing-instruction name="dbhtml"> |
---|
| 84 | <xsl:text>filename="</xsl:text> |
---|
| 85 | <xsl:value-of select="concat($id, $idsuffix)" /> |
---|
| 86 | <xsl:text>.html"</xsl:text> |
---|
| 87 | </xsl:processing-instruction> |
---|
[33cb2bd] | 88 | |
---|
| 89 | <xsl:for-each select="title"> |
---|
| 90 | <xsl:element name="title"> |
---|
| 91 | <xsl:copy-of select="@*|node()" /> |
---|
| 92 | <xsl:if test="contains($clfs.multilib, ',') and ($multibuild = 'true')"> |
---|
| 93 | <xsl:text> - </xsl:text> |
---|
| 94 | <xsl:choose> |
---|
| 95 | <xsl:when test="$bits = '32'"> |
---|
| 96 | <xsl:text>32Bit</xsl:text> |
---|
| 97 | </xsl:when> |
---|
| 98 | <xsl:when test="$bits = 'n32'"> |
---|
| 99 | <xsl:text>N32</xsl:text> |
---|
| 100 | </xsl:when> |
---|
| 101 | <xsl:when test="$bits = '64'"> |
---|
| 102 | <xsl:text>64Bit</xsl:text> |
---|
| 103 | </xsl:when> |
---|
| 104 | </xsl:choose> |
---|
| 105 | </xsl:if> |
---|
| 106 | </xsl:element> |
---|
| 107 | </xsl:for-each> |
---|
| 108 | |
---|
[4a39252] | 109 | <xsl:choose> |
---|
| 110 | <xsl:when test="$bits = '32'"> |
---|
[33cb2bd] | 111 | <xsl:apply-templates select="@*|node()[not(self::title)]" mode="filter-bits-32" /> |
---|
[4a39252] | 112 | </xsl:when> |
---|
| 113 | <xsl:when test="$bits = 'n32'"> |
---|
[33cb2bd] | 114 | <xsl:apply-templates select="@*|node()[not(self::title)]" mode="filter-bits-n32" /> |
---|
[4a39252] | 115 | </xsl:when> |
---|
| 116 | <xsl:when test="$bits = '64'"> |
---|
[33cb2bd] | 117 | <xsl:apply-templates select="@*|node()[not(self::title)]" mode="filter-bits-64" /> |
---|
[4a39252] | 118 | </xsl:when> |
---|
| 119 | </xsl:choose> |
---|
[33cb2bd] | 120 | |
---|
[4fe47e3] | 121 | </xsl:copy> |
---|
[33cb2bd] | 122 | |
---|
[4fe47e3] | 123 | </xsl:for-each> |
---|
[33cb2bd] | 124 | |
---|
[4fe47e3] | 125 | </xsl:template> |
---|
| 126 | |
---|
[4a39252] | 127 | <!-- Apply the profile to the 32bit package --> |
---|
| 128 | |
---|
| 129 | <xsl:template match="@*|node()" mode="filter-bits-32"> |
---|
| 130 | <xsl:variable name="ismultilib"> |
---|
| 131 | <xsl:choose> |
---|
| 132 | <xsl:when test="contains($clfs.multilib, ',')"> |
---|
| 133 | <xsl:text>true</xsl:text> |
---|
| 134 | </xsl:when> |
---|
| 135 | <xsl:otherwise> |
---|
| 136 | <xsl:text>false</xsl:text> |
---|
| 137 | </xsl:otherwise> |
---|
| 138 | </xsl:choose> |
---|
| 139 | </xsl:variable> |
---|
| 140 | <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))"> |
---|
| 141 | <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))"> |
---|
| 142 | <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',32,')"> |
---|
| 143 | <xsl:copy> |
---|
| 144 | <xsl:apply-templates select="@*|node()" mode="filter-bits-32" /> |
---|
| 145 | </xsl:copy> |
---|
| 146 | </xsl:if> |
---|
| 147 | </xsl:if> |
---|
| 148 | </xsl:if> |
---|
| 149 | </xsl:template> |
---|
| 150 | |
---|
| 151 | <xsl:template match="@c:arch" mode="filter-bits-32" /> |
---|
| 152 | <xsl:template match="@c:bits" mode="filter-bits-32" /> |
---|
| 153 | <xsl:template match="@c:multilib" mode="filter-bits-32" /> |
---|
| 154 | |
---|
| 155 | <!-- Apply the profile to the n32 package --> |
---|
| 156 | |
---|
| 157 | <xsl:template match="@*|node()" mode="filter-bits-n32"> |
---|
| 158 | <xsl:variable name="ismultilib"> |
---|
| 159 | <xsl:choose> |
---|
| 160 | <xsl:when test="contains($clfs.multilib, ',')"> |
---|
| 161 | <xsl:text>true</xsl:text> |
---|
| 162 | </xsl:when> |
---|
| 163 | <xsl:otherwise> |
---|
| 164 | <xsl:text>false</xsl:text> |
---|
| 165 | </xsl:otherwise> |
---|
| 166 | </xsl:choose> |
---|
| 167 | </xsl:variable> |
---|
| 168 | <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))"> |
---|
| 169 | <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))"> |
---|
| 170 | <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',n32,')"> |
---|
| 171 | <xsl:copy> |
---|
| 172 | <xsl:apply-templates select="@*|node()" mode="filter-bits-n32" /> |
---|
| 173 | </xsl:copy> |
---|
| 174 | </xsl:if> |
---|
| 175 | </xsl:if> |
---|
| 176 | </xsl:if> |
---|
| 177 | </xsl:template> |
---|
| 178 | |
---|
| 179 | <xsl:template match="@c:arch" mode="filter-bits-n32" /> |
---|
| 180 | <xsl:template match="@c:bits" mode="filter-bits-n32" /> |
---|
| 181 | <xsl:template match="@c:multilib" mode="filter-bits-n32" /> |
---|
| 182 | |
---|
| 183 | <!-- Apply the profile to the 64bit package --> |
---|
| 184 | |
---|
| 185 | <xsl:template match="@*|node()" mode="filter-bits-64"> |
---|
| 186 | <xsl:variable name="ismultilib"> |
---|
| 187 | <xsl:choose> |
---|
| 188 | <xsl:when test="contains($clfs.multilib, ',')"> |
---|
| 189 | <xsl:text>true</xsl:text> |
---|
| 190 | </xsl:when> |
---|
| 191 | <xsl:otherwise> |
---|
| 192 | <xsl:text>false</xsl:text> |
---|
| 193 | </xsl:otherwise> |
---|
| 194 | </xsl:choose> |
---|
| 195 | </xsl:variable> |
---|
| 196 | <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))"> |
---|
| 197 | <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))"> |
---|
| 198 | <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',64,')"> |
---|
| 199 | <xsl:copy> |
---|
| 200 | <xsl:apply-templates select="@*|node()" mode="filter-bits-64" /> |
---|
| 201 | </xsl:copy> |
---|
| 202 | </xsl:if> |
---|
| 203 | </xsl:if> |
---|
| 204 | </xsl:if> |
---|
| 205 | </xsl:template> |
---|
| 206 | |
---|
| 207 | <xsl:template match="@c:arch" mode="filter-bits-64" /> |
---|
| 208 | <xsl:template match="@c:bits" mode="filter-bits-64" /> |
---|
| 209 | <xsl:template match="@c:multilib" mode="filter-bits-64" /> |
---|
[4fe47e3] | 210 | |
---|
[4a39252] | 211 | <!-- Apply the profile filter to the entire document --> |
---|
[4fe47e3] | 212 | <xsl:template match="//*[@c:arch]|//*[@c:multilib]"> |
---|
| 213 | <xsl:variable name="ismultilib"> |
---|
| 214 | <xsl:choose> |
---|
| 215 | <xsl:when test="contains($clfs.multilib, ',')"> |
---|
| 216 | <xsl:text>true</xsl:text> |
---|
| 217 | </xsl:when> |
---|
| 218 | <xsl:otherwise> |
---|
| 219 | <xsl:text>false</xsl:text> |
---|
| 220 | </xsl:otherwise> |
---|
| 221 | </xsl:choose> |
---|
| 222 | </xsl:variable> |
---|
| 223 | <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))"> |
---|
| 224 | <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))"> |
---|
| 225 | <xsl:copy> |
---|
[4a39252] | 226 | <xsl:apply-templates select="@*|node()" /> |
---|
[4fe47e3] | 227 | </xsl:copy> |
---|
| 228 | </xsl:if> |
---|
| 229 | </xsl:if> |
---|
| 230 | </xsl:template> |
---|
| 231 | |
---|
[4a39252] | 232 | <!-- Remove the profileing attributes for the remaining objects --> |
---|
[4fe47e3] | 233 | <xsl:template match="@c:arch" /> |
---|
| 234 | <xsl:template match="@c:bits" /> |
---|
| 235 | <xsl:template match="@c:multilib" /> |
---|
| 236 | |
---|
| 237 | </xsl:stylesheet> |
---|