]> granicus.if.org Git - docbook-dsssl/commitdiff
Changed <link> to process its endterm if the element content
authorBob Stayton <bobs@sagehill.net>
Thu, 2 Aug 2001 19:16:27 +0000 (19:16 +0000)
committerBob Stayton <bobs@sagehill.net>
Thu, 2 Aug 2001 19:16:27 +0000 (19:16 +0000)
is empty.

xsl/html/xref.xsl

index 3762ad52957f98d4d96f92f3c724767b9d03fc29..d746e1626f62c016d3d06bb11d57a03c492f0166 100644 (file)
 </xsl:template>
 
 <xsl:template match="*" mode="endterm">
-  <xsl:apply-templates select="./node()"/>
+  <!-- Process the children of the endterm element -->
+  <xsl:apply-templates select="child::node()"/>
 </xsl:template>
 
 <!-- ==================================================================== -->
       </xsl:attribute>
     </xsl:if>
 
-    <xsl:apply-templates/>
+    <xsl:choose>
+      <xsl:when test="count(child::node()) &gt; 0">
+        <!-- If it has content, use it -->
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <!-- else look for an endterm -->
+        <xsl:choose>
+          <xsl:when test="@endterm">
+            <xsl:variable name="etargets" select="id(@endterm)"/>
+            <xsl:variable name="etarget" select="$etargets[1]"/>
+            <xsl:choose>
+              <xsl:when test="count($etarget) = 0">
+                <xsl:message>
+                  <xsl:value-of select="count($etargets)"/>
+                  <xsl:text>Endterm points to nonexistent ID: </xsl:text>
+                  <xsl:value-of select="@endterm"/>
+                </xsl:message>
+                <xsl:text>???</xsl:text>
+              </xsl:when>
+              <xsl:otherwise>
+                  <xsl:apply-templates select="$etarget" mode="endterm"/>
+              </xsl:otherwise>
+            </xsl:choose>
+          </xsl:when>
+        
+          <xsl:otherwise>
+            <xsl:message>
+              <xsl:text>Link element has no content and no Endterm. </xsl:text>
+              <xsl:text>Nothing to show in the link to </xsl:text>
+              <xsl:value-of select="$target"/>
+            </xsl:message>
+            <xsl:text>???</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:otherwise>
+    </xsl:choose>
   </a>
 </xsl:template>