]> granicus.if.org Git - docbook-dsssl/commitdiff
Enable support for html5 features, including using <section> instead of
authorBob Stayton <bobs@sagehill.net>
Sat, 12 May 2012 23:33:15 +0000 (23:33 +0000)
committerBob Stayton <bobs@sagehill.net>
Sat, 12 May 2012 23:33:15 +0000 (23:33 +0000)
<div> for certain elements, and setting heading level to <h1> for chapters.
These features are not changed in the base html stylesheet for backwards
compatibility.

xsl/html/component.xsl

index 1c1088b604e4269b219b120fade6f6f4eb5bb875..6d4d191642eaf77a8c1feec8869645ea8e8d727d 100644 (file)
 
 <!-- ==================================================================== -->
 
+<!-- Set to 2 for backwards compatibility -->
+<xsl:param name="component.heading.level" select="2"/>
+
 <xsl:template name="component.title">
   <xsl:param name="node" select="."/>
 
+  <!-- This handles the case where a component (bibliography, for example)
+       occurs inside a section; will we need parameters for this? -->
+
+  <!-- This "level" is a section level.  To compute <h> level, add 1. -->
   <xsl:variable name="level">
     <xsl:choose>
+      <!-- chapters and other book children should get <h1> -->
+      <xsl:when test="$node/parent::book">0</xsl:when>
       <xsl:when test="ancestor::section">
         <xsl:value-of select="count(ancestor::section)+1"/>
       </xsl:when>
@@ -31,9 +40,6 @@
     </xsl:choose>
   </xsl:variable>
 
-  <!-- Let's handle the case where a component (bibliography, for example)
-       occurs inside a section; will we need parameters for this? -->
-
   <xsl:element name="h{$level+1}">
     <xsl:attribute name="class">title</xsl:attribute>
     <xsl:call-template name="id.attribute"/>
 <xsl:template match="preface">
   <xsl:call-template name="id.warning"/>
 
-  <div>
+  <xsl:element name="{$div.element}">
     <xsl:call-template name="common.html.attributes">
       <xsl:with-param name="inherit" select="1"/>
     </xsl:call-template>
     </xsl:if>
     <xsl:apply-templates/>
     <xsl:call-template name="process.footnotes"/>
-  </div>
+  </xsl:element>
 </xsl:template>
 
 <xsl:template match="preface/title" mode="titlepage.mode" priority="2">
 <xsl:template match="chapter">
   <xsl:call-template name="id.warning"/>
 
-  <div>
+  <xsl:element name="{$div.element}">
     <xsl:call-template name="common.html.attributes">
       <xsl:with-param name="inherit" select="1"/>
     </xsl:call-template>
     </xsl:if>
     <xsl:apply-templates/>
     <xsl:call-template name="process.footnotes"/>
-  </div>
+  </xsl:element>
 </xsl:template>
 
 <xsl:template match="chapter/title|chapter/chapterinfo/title|chapter/info/title"
 
   <xsl:call-template name="id.warning"/>
 
-  <div>
+  <xsl:element name="{$div.element}">
     <xsl:call-template name="common.html.attributes">
       <xsl:with-param name="inherit" select="1"/>
     </xsl:call-template>
     <xsl:if test="not(parent::article) or $ischunk != 0">
       <xsl:call-template name="process.footnotes"/>
     </xsl:if>
-  </div>
+  </xsl:element>
 </xsl:template>
 
 <xsl:template match="appendix/title|appendix/appendixinfo/title"
 <xsl:template match="article">
   <xsl:call-template name="id.warning"/>
 
-  <div>
+  <xsl:element name="{$div.element}">
     <xsl:call-template name="common.html.attributes">
       <xsl:with-param name="inherit" select="1"/>
     </xsl:call-template>
 
     <xsl:apply-templates/>
     <xsl:call-template name="process.footnotes"/>
-  </div>
+  </xsl:element>
 </xsl:template>
 
 <xsl:template match="article/title|article/articleinfo/title" mode="titlepage.mode" priority="2">
 <xsl:template match="topic">
   <xsl:call-template name="id.warning"/>
 
-  <div>
+  <xsl:element name="{$div.element}">
     <xsl:call-template name="common.html.attributes">
       <xsl:with-param name="inherit" select="1"/>
     </xsl:call-template>
     <xsl:apply-templates/>
 
     <xsl:call-template name="process.footnotes"/>
-  </div>
+  </xsl:element>
 </xsl:template>
 
 <xsl:template match="topic/title|topic/info/title" mode="titlepage.mode" priority="2">