]> granicus.if.org Git - docbook-dsssl/commitdiff
Added template named common.html.attributes to output
authorBob Stayton <bobs@sagehill.net>
Wed, 18 Mar 2009 07:47:14 +0000 (07:47 +0000)
committerBob Stayton <bobs@sagehill.net>
Wed, 18 Mar 2009 07:47:14 +0000 (07:47 +0000)
class, title, lang, and dir for most elements.
Started adding it to some list and block elements.

xsl/html/block.xsl
xsl/html/html.xsl
xsl/html/lists.xsl

index c84bd80bd6093c7f25ad39bf7619f62a0ed6e4eb..67bc416ac77d53a9c3e11b7ca3782d5e965b148d 100644 (file)
 
 <xsl:template match="blockquote">
   <div>
-    <xsl:apply-templates select="." mode="class.attribute"/>
-    <xsl:if test="@lang or @xml:lang">
-      <xsl:call-template name="language.attribute"/>
-    </xsl:if>
+    <xsl:call-template name="common.html.attributes"/>
     <xsl:call-template name="anchor"/>
 
     <xsl:choose>
index 6e507b16fb4a318c599a9a11719cea1b792db0d7..9df66349d3f72c23d930fad81286140072dcb4ac 100644 (file)
     </xsl:call-template>
   </xsl:variable>
 
+  <xsl:variable name="has.title.markup">
+    <xsl:apply-templates select="." mode="title.markup">
+      <xsl:with-param name="verbose" select="0"/>
+    </xsl:apply-templates>
+  </xsl:variable>
+
   <xsl:variable name="gentext.title">
-    <xsl:if test="$is.title != 0 or
+    <xsl:if test="$has.title.markup != '???TITLE???' and
+                  ($is.title != 0 or
                   $is.title-numbered != 0 or
-                  $is.title-unnumbered != 0">
+                  $is.title-unnumbered != 0)">
       <xsl:apply-templates select="."
                            mode="object.title.markup.textonly"/>
     </xsl:if>
   </xsl:if>
 </xsl:template>
 
+<xsl:template name="generate.class.attribute">
+  <xsl:apply-templates select="." mode="class.attribute"/>
+</xsl:template>
+
 <xsl:template match="*" mode="class.attribute">
   <xsl:param name="class" select="local-name(.)"/>
   <!-- permit customization of class attributes -->
   <xsl:value-of select="$class"/>
 </xsl:template>
 
+<!-- Apply common attributes such as class, lang, dir -->
+<xsl:template name="common.html.attributes">
+  <xsl:apply-templates select="." mode="common.html.attributes"/>
+</xsl:template>
+
+<xsl:template match="*" mode="common.html.attributes">
+  <xsl:call-template name="generate.html.lang"/>
+  <xsl:call-template name="dir"/>
+  <xsl:call-template name="generate.class.attribute"/>
+  <xsl:call-template name="generate.html.title"/>
+</xsl:template>
+
+<!-- Pass through any lang attributes -->
+<xsl:template name="generate.html.lang">
+  <xsl:apply-templates select="." mode="html.lang.attribute"/>
+</xsl:template>
+
+<xsl:template match="*" mode="html.lang.attribute">
+  <!-- match the attribute name to the output type -->
+  <xsl:choose>
+    <xsl:when test="@lang and $stylesheet.result.type = 'html'">
+      <xsl:attribute name="lang">
+        <xsl:value-of select="@lang"/>
+      </xsl:attribute>
+    </xsl:when>
+    <xsl:when test="@lang and $stylesheet.result.type = 'xhtml'">
+      <xsl:attribute name="xml:lang">
+        <xsl:value-of select="@lang"/>
+      </xsl:attribute>
+    </xsl:when>
+    <xsl:when test="@xml:lang and $stylesheet.result.type = 'html'">
+      <xsl:attribute name="lang">
+        <xsl:value-of select="@xml:lang"/>
+      </xsl:attribute>
+    </xsl:when>
+    <xsl:when test="@xml:lang and $stylesheet.result.type = 'xhtml'">
+      <xsl:attribute name="xml:lang">
+        <xsl:value-of select="@xml:lang"/>
+      </xsl:attribute>
+    </xsl:when>
+  </xsl:choose>
+</xsl:template>
+
 </xsl:stylesheet>
 
index 1cc78b4721080edc6af3a2afcc21586e0f60db2c..06e999de1d5fd016cb8202b7157a17213b339036 100644 (file)
                 |processing-instruction()[not(preceding-sibling::step)]"/>
 
   <div>
-    <xsl:apply-templates select="." mode="class.attribute"/>
+    <xsl:call-template name="common.html.attributes"/>
     <xsl:call-template name="anchor">
       <xsl:with-param name="conditional">
         <xsl:choose>
   <xsl:call-template name="anchor"/>
 
   <ol type="{$numeration}">
+    <xsl:call-template name="common.html.attributes"/>
     <xsl:apply-templates/>
   </ol>
 </xsl:template>
 
 <xsl:template match="step">
   <li>
+    <xsl:call-template name="common.html.attributes"/>
     <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </li>