Changeset 4a39252


Ignore:
Timestamp:
Mar 5, 2011, 7:35:51 PM (13 years ago)
Author:
Joe Ciccone <jciccone@…>
Children:
5508d22
Parents:
d17cfb8
Message:

Properly filter the descendents of c:package based on the filtering
attributes that are set. This marks a point where the stylesheet is stable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOOK/stylesheets/clfs-profile.xsl

    rd17cfb8 r4a39252  
    1515  <xsl:param name="clfs.arch" select="''" />
    1616  <xsl:param name="clfs.multilib" select="''" />
    17  
     17
    1818  <!-- Apply the other templates -->
    1919  <xsl:template match="@*|node()" priority="-1">
     
    2323  </xsl:template>
    2424
     25  <!-- Build the package xml -->
    2526  <xsl:template match="//c:package">
    2627    <xsl:param name="id" select="@id" />
     
    7778
    7879    <xsl:for-each select="sect1">
     80
    7981      <xsl:copy>
    8082        <xsl:attribute name="id">
    8183          <xsl:value-of select="concat($id, $idsuffix)" />
     84        </xsl:attribute>
     85        <xsl:attribute name="role">
     86          <xsl:text>package</xsl:text>
    8287        </xsl:attribute>
    8388        <xsl:processing-instruction name="dbhtml">
     
    8691          <xsl:text>.html&quot;</xsl:text>
    8792        </xsl:processing-instruction>
    88         <xsl:apply-templates select="child::node()[(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), concat(',', $bits, ','))]" />
     93        <xsl:choose>
     94          <xsl:when test="$bits = '32'">
     95            <xsl:apply-templates select="@*|node()" mode="filter-bits-32" />
     96          </xsl:when>
     97          <xsl:when test="$bits = 'n32'">
     98            <xsl:apply-templates select="@*|node()" mode="filter-bits-n32" />
     99          </xsl:when>
     100          <xsl:when test="$bits = '64'">
     101            <xsl:apply-templates select="@*|node()" mode="filter-bits-64" />
     102          </xsl:when>
     103        </xsl:choose>
    89104      </xsl:copy>
    90105    </xsl:for-each>
    91106  </xsl:template>
    92107
    93   <!-- Apply the build profile filter -->
    94 
     108  <!-- Apply the profile to the 32bit package -->
     109
     110  <xsl:template match="@*|node()" mode="filter-bits-32">
     111    <xsl:variable name="ismultilib">
     112      <xsl:choose>
     113        <xsl:when test="contains($clfs.multilib, ',')">
     114          <xsl:text>true</xsl:text>
     115        </xsl:when>
     116        <xsl:otherwise>
     117          <xsl:text>false</xsl:text>
     118        </xsl:otherwise>
     119      </xsl:choose>
     120    </xsl:variable>
     121    <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
     122      <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
     123        <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',32,')">
     124          <xsl:copy>
     125            <xsl:apply-templates select="@*|node()" mode="filter-bits-32" />
     126          </xsl:copy>
     127        </xsl:if>
     128      </xsl:if>
     129    </xsl:if>
     130  </xsl:template>
     131
     132  <xsl:template match="@c:arch" mode="filter-bits-32" />
     133  <xsl:template match="@c:bits" mode="filter-bits-32" />
     134  <xsl:template match="@c:multilib" mode="filter-bits-32" />
     135
     136  <!-- Apply the profile to the n32 package -->
     137
     138  <xsl:template match="@*|node()" mode="filter-bits-n32">
     139    <xsl:variable name="ismultilib">
     140      <xsl:choose>
     141        <xsl:when test="contains($clfs.multilib, ',')">
     142          <xsl:text>true</xsl:text>
     143        </xsl:when>
     144        <xsl:otherwise>
     145          <xsl:text>false</xsl:text>
     146        </xsl:otherwise>
     147      </xsl:choose>
     148    </xsl:variable>
     149    <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
     150      <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
     151        <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',n32,')">
     152          <xsl:copy>
     153            <xsl:apply-templates select="@*|node()" mode="filter-bits-n32" />
     154          </xsl:copy>
     155        </xsl:if>
     156      </xsl:if>
     157    </xsl:if>
     158  </xsl:template>
     159
     160  <xsl:template match="@c:arch" mode="filter-bits-n32" />
     161  <xsl:template match="@c:bits" mode="filter-bits-n32" />
     162  <xsl:template match="@c:multilib" mode="filter-bits-n32" />
     163
     164  <!-- Apply the profile to the 64bit package -->
     165
     166  <xsl:template match="@*|node()" mode="filter-bits-64">
     167    <xsl:variable name="ismultilib">
     168      <xsl:choose>
     169        <xsl:when test="contains($clfs.multilib, ',')">
     170          <xsl:text>true</xsl:text>
     171        </xsl:when>
     172        <xsl:otherwise>
     173          <xsl:text>false</xsl:text>
     174        </xsl:otherwise>
     175      </xsl:choose>
     176    </xsl:variable>
     177    <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
     178      <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
     179        <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',64,')">
     180          <xsl:copy>
     181            <xsl:apply-templates select="@*|node()" mode="filter-bits-64" />
     182          </xsl:copy>
     183        </xsl:if>
     184      </xsl:if>
     185    </xsl:if>
     186  </xsl:template>
     187
     188  <xsl:template match="@c:arch" mode="filter-bits-64" />
     189  <xsl:template match="@c:bits" mode="filter-bits-64" />
     190  <xsl:template match="@c:multilib" mode="filter-bits-64" />
     191
     192  <!-- Apply the profile filter to the entire document -->
    95193  <xsl:template match="//*[@c:arch]|//*[@c:multilib]">
    96194    <xsl:variable name="ismultilib">
     
    107205      <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
    108206        <xsl:copy>
    109           <xsl:apply-templates select="@*|node()"/>
     207          <xsl:apply-templates select="@*|node()" />
    110208        </xsl:copy>
    111209      </xsl:if>
     
    113211  </xsl:template>
    114212
    115   <!-- Remove the profiling attributes specific to this stylesheet -->
    116 
     213  <!-- Remove the profileing attributes for the remaining objects -->
    117214  <xsl:template match="@c:arch" />
    118215  <xsl:template match="@c:bits" />
Note: See TracChangeset for help on using the changeset viewer.