]> granicus.if.org Git - docbook-dsssl/commitdiff
Create separate templates for computing label of question and answer
authorBob Stayton <bobs@sagehill.net>
Sat, 14 Mar 2009 00:00:40 +0000 (00:00 +0000)
committerBob Stayton <bobs@sagehill.net>
Sat, 14 Mar 2009 00:00:40 +0000 (00:00 +0000)
in a qandaentry, so such can be used for the alt text of an xref
to a qandaentry.

xsl/html/html.xsl
xsl/html/qandaset.xsl

index 43c317d7b2766b3a79e20f499dbd541ca4cd750c..6e507b16fb4a318c599a9a11719cea1b792db0d7 100644 (file)
       </xsl:attribute>
     </xsl:when>
   </xsl:choose>
+</xsl:template>
+
+<xsl:template match="qandaentry" mode="html.title.attribute">
+  <xsl:apply-templates select="question" mode="html.title.attribute"/>
+</xsl:template>
+
+<xsl:template match="question" mode="html.title.attribute">
+  <xsl:variable name="label.text">
+    <xsl:apply-templates select="." mode="qanda.label"/>
+  </xsl:variable>
 
+  <xsl:choose>
+    <xsl:when test="string-length($label.text) != 0">
+      <xsl:attribute name="title">
+        <xsl:value-of select="$label.text"/>
+      </xsl:attribute>
+    </xsl:when>
+    <!-- Fall back to alt if available -->
+    <xsl:when test="alt">
+      <xsl:attribute name="title">
+        <xsl:value-of select="normalize-space(alt)"/>
+      </xsl:attribute>
+    </xsl:when>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template name="dir">
index 6d102a0791e962ce48ecf5e42bd9d72927f594fa..9c551bc8994021936938681f28ee92323d536a06 100644 (file)
 
 <xsl:template match="question">
   <xsl:variable name="deflabel">
-    <xsl:choose>
-      <xsl:when test="ancestor-or-self::*[@defaultlabel]">
-        <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
-                              /@defaultlabel"/>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:value-of select="$qanda.defaultlabel"/>
-      </xsl:otherwise>
-    </xsl:choose>
+    <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
   </xsl:variable>
 
   <tr>
       </xsl:call-template>
 
       <xsl:variable name="label.content">
-        <xsl:apply-templates select="." mode="label.markup"/>
-        <xsl:if test="$deflabel = 'number' and not(label)">
-          <xsl:apply-templates select="." mode="intralabel.punctuation"/>
-        </xsl:if>
+        <xsl:apply-templates select="." mode="qanda.label"/>
       </xsl:variable>
 
       <xsl:if test="string-length($label.content) &gt; 0">
   </tr>
 </xsl:template>
 
+<xsl:template match="*" mode="qanda.defaultlabel">
+  <xsl:choose>
+    <xsl:when test="ancestor-or-self::*[@defaultlabel]">
+      <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
+                            /@defaultlabel"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$qanda.defaultlabel"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="question" mode="qanda.label">
+  <xsl:variable name="deflabel">
+    <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
+  </xsl:variable>
+  <xsl:apply-templates select="." mode="label.markup"/>
+  <xsl:if test="$deflabel = 'number' and not(label)">
+    <xsl:apply-templates select="." mode="intralabel.punctuation"/>
+  </xsl:if>
+</xsl:template>
+
 <xsl:template match="answer">
   <xsl:variable name="deflabel">
-    <xsl:choose>
-      <xsl:when test="ancestor-or-self::*[@defaultlabel]">
-        <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
-                              /@defaultlabel"/>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:value-of select="$qanda.defaultlabel"/>
-      </xsl:otherwise>
-    </xsl:choose>
+    <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
   </xsl:variable>
 
   <tr class="{local-name(.)}">
   </tr>
 </xsl:template>
 
+<xsl:template match="answer" mode="qanda.label">
+  <xsl:apply-templates select="." mode="label.markup"/>
+</xsl:template>
+
 <xsl:template match="label">
   <xsl:apply-templates/>
 </xsl:template>