source: BOOK/stylesheets/clfs-profile.xsl @ d17cfb8

Last change on this file since d17cfb8 was 4fe47e3, checked in by Joe Ciccone <jciccone@…>, 13 years ago

Add the initial changes for a new xml format for the packages part
of the book. This is still preliminary and currently is pretty
broken, more to come in the future as bugs get squashed.

  • Property mode set to 100644
File size: 4.6 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3  xmlns="http://www.w3.org/1999/xhtml"
4  xmlns:c="http://schema.cross-lfs.org/book"
5  version="1.0">
6
7  <!-- Declare our output type -->
8  <xsl:output method="xml"
9    indent="no"
10    omit-xml-declaration="no"
11    encoding="utf-8"
12    doctype-public="-//OASIS//DTD DocBook XML V4.5//EN"
13    doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" />
14
15  <xsl:param name="clfs.arch" select="''" />
16  <xsl:param name="clfs.multilib" select="''" />
17 
18  <!-- Apply the other templates -->
19  <xsl:template match="@*|node()" priority="-1">
20    <xsl:copy>
21      <xsl:apply-templates select="@*|node()" />
22    </xsl:copy>
23  </xsl:template>
24
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    <xsl:choose>
40      <xsl:when test="$multibuild = 'true'">
41        <xsl:variable name="currentbits" select="substring-before(concat($bits, ','), ',')" />
42        <xsl:variable name="remainingbits" select="substring-after($bits, ',')" />
43        <xsl:call-template name="package-stub">
44          <xsl:with-param name="id" select="$id" />
45          <xsl:with-param name="idsuffix">
46            <xsl:if test="$remainingbits">
47              <xsl:value-of select="concat('-', $currentbits)" />
48            </xsl:if>
49          </xsl:with-param>
50          <xsl:with-param name="bits" select="substring-before(concat($bits, ','), ',')" />
51        </xsl:call-template>
52        <xsl:if test="$remainingbits">
53          <xsl:text>
54
55          </xsl:text>
56          <xsl:call-template name="package-iterator">
57            <xsl:with-param name="id" select="$id" />
58            <xsl:with-param name="multibuild" select="$multibuild" />
59            <xsl:with-param name="bits" select="$remainingbits" />
60          </xsl:call-template>
61        </xsl:if>
62      </xsl:when>
63      <xsl:otherwise>
64        <xsl:call-template name="package-stub">
65          <xsl:with-param name="id" select="$id" />
66          <xsl:with-param name="idsuffix" />
67          <xsl:with-param name="bits" select="substring-before(concat($bits, ','), ',')" />
68        </xsl:call-template>
69      </xsl:otherwise>
70    </xsl:choose>
71  </xsl:template>
72
73  <xsl:template name="package-stub">
74    <xsl:param name="id" /> <!-- Base ID of the resulting package -->
75    <xsl:param name="idsuffix" /> <!-- Suffix to attach to the end of the ID for this perticular instance -->
76    <xsl:param name="bits" /> <!-- Which bit sizes to create a package for -->
77
78    <xsl:for-each select="sect1">
79      <xsl:copy>
80        <xsl:attribute name="id">
81          <xsl:value-of select="concat($id, $idsuffix)" />
82        </xsl:attribute>
83        <xsl:processing-instruction name="dbhtml">
84          <xsl:text>filename=&quot;</xsl:text>
85          <xsl:value-of select="concat($id, $idsuffix)" />
86          <xsl:text>.html&quot;</xsl:text>
87        </xsl:processing-instruction>
88        <xsl:apply-templates select="child::node()[(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), concat(',', $bits, ','))]" />
89      </xsl:copy>
90    </xsl:for-each>
91  </xsl:template>
92
93  <!-- Apply the build profile filter -->
94
95  <xsl:template match="//*[@c:arch]|//*[@c:multilib]">
96    <xsl:variable name="ismultilib">
97      <xsl:choose>
98        <xsl:when test="contains($clfs.multilib, ',')">
99          <xsl:text>true</xsl:text>
100        </xsl:when>
101        <xsl:otherwise>
102          <xsl:text>false</xsl:text>
103        </xsl:otherwise>
104      </xsl:choose>
105    </xsl:variable>
106    <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
107      <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
108        <xsl:copy>
109          <xsl:apply-templates select="@*|node()"/>
110        </xsl:copy>
111      </xsl:if>
112    </xsl:if>
113  </xsl:template>
114
115  <!-- Remove the profiling attributes specific to this stylesheet -->
116
117  <xsl:template match="@c:arch" />
118  <xsl:template match="@c:bits" />
119  <xsl:template match="@c:multilib" />
120
121</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.