]> granicus.if.org Git - docbook-dsssl/commitdiff
Bug #464487: use (new) anchor template to consistently generate HTML anchors (usually...
authorNorman Walsh <ndw@nwalsh.com>
Wed, 26 Sep 2001 18:36:34 +0000 (18:36 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Wed, 26 Sep 2001 18:36:34 +0000 (18:36 +0000)
21 files changed:
xsl/html/admon.xsl
xsl/html/biblio.xsl
xsl/html/block.xsl
xsl/html/callout.xsl
xsl/html/component.xsl
xsl/html/division.xsl
xsl/html/ebnf.xsl
xsl/html/formal.xsl
xsl/html/glossary.xsl
xsl/html/graphics.xsl
xsl/html/html.xsl
xsl/html/index.xsl
xsl/html/inline.xsl
xsl/html/lists.xsl
xsl/html/qandaset.xsl
xsl/html/refentry.xsl
xsl/html/sections.xsl
xsl/html/synop.xsl
xsl/html/table.xsl
xsl/html/verbatim.xsl
xsl/html/xref.xsl

index 09eae16fe81d21eb775bf7d43fcc6f7a50c413e6..c3f8e60105853cd978451549a930ab38bd35f181 100644 (file)
         </img>
       </td>
       <th>
-        <a>
-          <xsl:attribute name="name">
-            <xsl:call-template name="object.id"/>
-          </xsl:attribute>
-        </a>
+        <xsl:call-template name="anchor"/>
         <xsl:apply-templates select="." mode="object.title.markup"/>
       </th>
     </tr>
     </xsl:if>
 
     <h3 class="title">
-      <a>
-        <xsl:attribute name="name">
-          <xsl:call-template name="object.id"/>
-        </xsl:attribute>
-      </a>
+      <xsl:call-template name="anchor"/>
       <xsl:apply-templates select="." mode="object.title.markup"/>
     </h3>
 
 <xsl:template match="caution/title"></xsl:template>
 <xsl:template match="tip/title"></xsl:template>
 
-<xsl:template match="title" mode="admonition.title.mode">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select=".."/>
-    </xsl:call-template>
-  </xsl:variable>
-  <h3 class="title">
-    <a name="{$id}">
-      <xsl:apply-templates/>
-    </a>
-  </h3>
-</xsl:template>
-
-<xsl:template match="title" mode="graphic.admonition.title.mode">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select=".."/>
-    </xsl:call-template>
-  </xsl:variable>
-  <b class="title">
-    <a name="{$id}">
-      <xsl:apply-templates/>
-    </a>
-  </b>
-</xsl:template>
-
 </xsl:stylesheet>
index 8a8930b643e5099fc44c5670d6b6e94ade6ee086..4be40be638a195c0546dd2cd9585e2bd539ba97c 100644 (file)
 <xsl:template match="bibliography/titleabbrev"></xsl:template>
 
 <xsl:template match="bibliography/title" mode="component.title.mode">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select=".."/>
-    </xsl:call-template>
-  </xsl:variable>
   <h2 class="title">
-    <a name="{$id}">
-      <xsl:apply-templates/>
-    </a>
+    <xsl:call-template name="anchor">
+      <xsl:with-param name="node" select=".."/>
+    </xsl:call-template>
+    <xsl:apply-templates/>
   </h2>
 </xsl:template>
 
 </xsl:template>
 
 <xsl:template match="bibliodiv/title">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select=".."/>
-    </xsl:call-template>
-  </xsl:variable>
   <h3 class="{name(.)}">
-    <a name="{$id}">
-      <xsl:apply-templates/>
-    </a>
+    <xsl:call-template name="anchor">
+      <xsl:with-param name="node" select=".."/>
+    </xsl:call-template>
+    <xsl:apply-templates/>
   </h3>
 </xsl:template>
 
 <!-- ==================================================================== -->
 
 <xsl:template match="biblioentry">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
   <xsl:choose>
     <xsl:when test="string(.) = ''">
       <xsl:variable name="bib" select="document($bibliography.collection)"/>
@@ -88,8 +83,8 @@
             <xsl:text> found in </xsl:text>
             <xsl:value-of select="$bibliography.collection"/>
           </xsl:message>
-          <div id="{$id}" class="{name(.)}">
-            <a name="{$id}"/>
+          <div class="{name(.)}">
+            <xsl:call-template name="anchor"/>
             <p>
               <xsl:text>Error: no bibliography entry: </xsl:text>
               <xsl:value-of select="$id"/>
       </xsl:choose>
     </xsl:when>
     <xsl:otherwise>
-      <div id="{$id}" class="{name(.)}">
-        <a name="{$id}"/>
+      <div class="{name(.)}">
+        <xsl:call-template name="anchor"/>
         <p>
           <xsl:apply-templates mode="bibliography.mode"/>
         </p>
 </xsl:template>
 
 <xsl:template match="bibliomixed">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
   <xsl:choose>
     <xsl:when test="string(.) = ''">
       <xsl:variable name="bib" select="document($bibliography.collection)"/>
             <xsl:value-of select="$bibliography.collection"/>
           </xsl:message>
           <div id="{$id}" class="{name(.)}">
-            <a name="{$id}"/>
+            <xsl:call-template name="anchor"/>
             <p>
               <xsl:text>Error: no bibliography entry: </xsl:text>
               <xsl:value-of select="$id"/>
     </xsl:when>
     <xsl:otherwise>
       <div id="{$id}" class="{name(.)}">
-        <a name="{$id}"/>
+        <xsl:call-template name="anchor"/>
         <p>
           <xsl:choose>
             <xsl:when test="local-name(*[1]) = 'abbrev'">
index 815ac868b22510ffcb0af320f8f8b39b4a7be72a..399fb0176a6a6829344244b1b608dadf958aec58 100644 (file)
 
 <xsl:template name="block.object">
   <div class="{name(.)}">
-    <a>
-      <xsl:attribute name="name">
-        <xsl:call-template name="object.id"/>
-      </xsl:attribute>
-    </a>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </div>
 </xsl:template>
 <xsl:template match="para">
   <p>
     <xsl:if test="position() = 1 and parent::listitem">
-      <a>
-        <xsl:attribute name="name">
-          <xsl:call-template name="object.id">
-            <xsl:with-param name="object" select="parent::listitem"/>
-          </xsl:call-template>
-        </xsl:attribute>
-      </a>
+      <xsl:call-template name="anchor">
+        <xsl:with-param name="node" select="parent::listitem"/>
+      </xsl:call-template>
     </xsl:if>
 
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </p>
 </xsl:template>
 <xsl:template match="simpara">
   <!-- see also listitem/simpara in lists.xsl -->
   <p>
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </p>
 </xsl:template>
 
 <xsl:template match="formalpara">
   <p>
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </p>
 </xsl:template>
@@ -90,9 +76,7 @@
 <!-- ==================================================================== -->
 
 <xsl:template match="blockquote">
-  <xsl:if test="@id">
-    <a name="{@id}"/>
-  </xsl:if>
+  <xsl:call-template name="anchor"/>
   <xsl:choose>
     <xsl:when test="attribution">
       <table border="0" width="100%"
 
 <xsl:template match="sidebar">
   <div class="{name(.)}">
-    <a>
-      <xsl:attribute name="name">
-        <xsl:call-template name="object.id"/>
-      </xsl:attribute>
-    </a>
-
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </div>
 </xsl:template>
index 9af572252dc23529ee12ae0a3bc90332e38aa3db..c591a9e5ba0daecea41abb61edd43463967120eb 100644 (file)
@@ -89,7 +89,7 @@
 </xsl:template>
 
 <xsl:template match="co">
-  <a name="{@id}"/>
+  <xsl:call-template name="anchor"/>
   <xsl:apply-templates select="." mode="callout-bug"/>
 </xsl:template>
 
index ea98b84a2f9b503d2d218abc658eaa585311fa19..7c4395eea3a20990208262725295d0fbe6e66e84 100644 (file)
 
 <xsl:template name="component.title">
   <xsl:param name="node" select="."/>
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select="$node"/>
-    </xsl:call-template>
-  </xsl:variable>
-
   <h2 class="title">
-    <a name="{$id}"/>
+    <xsl:call-template name="anchor">
+      <xsl:with-param name="node" select="$node"/>
+    </xsl:call-template>
     <xsl:apply-templates select="$node" mode="object.title.markup"/>
   </h2>
 </xsl:template>
@@ -54,8 +50,7 @@
 <!-- ==================================================================== -->
 
 <xsl:template match="dedication" mode="dedication">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
-  <div id="{$id}" class="{name(.)}">
+  <div class="{name(.)}">
     <xsl:call-template name="dedication.titlepage"/>
     <xsl:apply-templates/>
     <xsl:call-template name="process.footnotes"/>
 <!-- ==================================================================== -->
 
 <xsl:template match="preface">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
-  <div id="{$id}" class="{name(.)}">
+  <div class="{name(.)}">
     <xsl:call-template name="component.separator"/>
     <xsl:call-template name="preface.titlepage"/>
     <xsl:if test="$generate.preface.toc != '0'">
index 63760ee8b5121e254b4aa193f21b19d8e4a40a52..fa9a7138baf13f96aece3e9e3d3b8934e6abd361 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="set">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
-  <div class="{name(.)}" id="{$id}">
+  <div class="{name(.)}">
     <xsl:call-template name="set.titlepage"/>
     <xsl:if test="$generate.set.toc != '0'">
       <xsl:call-template name="set.toc"/>
 <!-- ==================================================================== -->
 
 <xsl:template match="book">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
-  <div class="{name(.)}" id="{$id}">
+  <div class="{name(.)}">
     <xsl:call-template name="book.titlepage"/>
     <xsl:apply-templates select="dedication" mode="dedication"/>
     <xsl:if test="$generate.book.toc != '0'">
 <!-- ==================================================================== -->
 
 <xsl:template match="part">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
-  <div class="{name(.)}" id="{$id}">
+  <div class="{name(.)}">
     <xsl:call-template name="part.titlepage"/>
     <xsl:if test="not(partintro) and $generate.part.toc != '0'">
       <xsl:call-template name="division.toc"/>
 <xsl:template match="partintro/subtitle"></xsl:template>
 
 <xsl:template match="partintro/title" mode="partintro.title.mode">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select=".."/>
-    </xsl:call-template>
-  </xsl:variable>
   <h2>
-    <a name="{$id}">
-      <xsl:apply-templates/>
-    </a>
+    <xsl:apply-templates/>
   </h2>
 </xsl:template>
 
index 117eec57cae459d60ba54867167610ac4a22d15d..9cbdc3dd1920105657fd9cdf906068528edbe61e 100644 (file)
@@ -127,7 +127,6 @@ borders, otherwise they don't.</para>
 
 <xsl:template match="production">
   <xsl:param name="recap" select="false()"/>
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
   <tr>
     <td align="left" valign="top" width="3%">
       <xsl:text>[</xsl:text>
@@ -147,7 +146,7 @@ borders, otherwise they don't.</para>
          </a>
        </xsl:when>
        <xsl:otherwise>
-         <a name="{$id}"/>
+          <xsl:call-template name="anchor"/>
          <xsl:apply-templates select="lhs"/>
        </xsl:otherwise>
       </xsl:choose>
@@ -334,9 +333,8 @@ borders, otherwise they don't.</para>
 </xsl:template>
 
 <xsl:template match="constraintdef">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
   <div class="{name(.)}">
-    <a name="{$id}"/>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </div>
 </xsl:template>
index 1d1a0cb1ef4ad2a30e14fa79780a68554bc89f68..fda3c0d9111ba939a363536631ef53d9478aadc7 100644 (file)
 
 <xsl:template name="formal.object.heading">
   <p>
-    <a>
-      <xsl:attribute name="name">
-       <xsl:call-template name="object.id"/>
-      </xsl:attribute>
-    </a>
+    <xsl:call-template name="anchor"/>
     <b>
       <xsl:apply-templates select="." mode="object.title.markup">
         <xsl:with-param name="allow-anchors" select="1"/>
 </xsl:template>
 
 <xsl:template name="informal.object">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
-
-  <div class="{name(.)}" id="{$id}">
+  <div class="{name(.)}">
     <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
-    <a name="{$id}"/>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
     <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
   </div>
index 138cb916f38abdaa4f818cff8594fdf31455f743..fe3e836d6324303d9cf3be7020949d722ff0fe7b 100644 (file)
 
 <xsl:template match="glosslist">
   <div class="{name(.)}">
-    <a>
-      <xsl:attribute name="name">
-        <xsl:call-template name="object.id"/>
-      </xsl:attribute>
-    </a>
-
+    <xsl:call-template name="anchor"/>
     <dl>
       <xsl:apply-templates/>
     </dl>
@@ -117,15 +112,10 @@ GlossEntry ::=
 
 <xsl:template match="glossentry/glossterm[1]" priority="2">
   <dt>
-    <a>
-      <xsl:attribute name="name">
-        <xsl:call-template name="object.id">
-           <xsl:with-param name="object" select=".."/>
-        </xsl:call-template>
-      </xsl:attribute>
-
-      <xsl:apply-templates/>
-    </a>
+    <xsl:call-template name="anchor">
+      <xsl:with-param name="node" select=".."/>
+    </xsl:call-template>
+    <xsl:apply-templates/>
   </dt>
 </xsl:template>
 
index d49c10e4f805f16058bcdcbc642e7e86443e6592..c8153fbf4a3dd3ff20c52fd8876dfc6f6f18c7a0 100644 (file)
 
 <xsl:template match="graphic">
   <p>
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:call-template name="process.image"/>
   </p>
 </xsl:template>
index 839c8ac682cd15336a79e62e2b8369bbd286af35..2d773f8dac1f9a3d9db2abd3dc426dc198508746 100644 (file)
 
      ******************************************************************** -->
 
+<xsl:template name="anchor">
+  <xsl:param name="node" select="."/>
+  <xsl:param name="conditional" select="1"/>
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id">
+      <xsl:with-param name="object" select="$node"/>
+    </xsl:call-template>
+  </xsl:variable>
+  <xsl:if test="$conditional = 0 or $node/@id">
+    <a name="{$id}"/>
+  </xsl:if>
+</xsl:template>
+
 <xsl:template name="dingbat">
   <xsl:param name="dingbat">bullet</xsl:param>
   <xsl:choose>
index dbfe89d25175206a3f39586a8de1928753f3d675..7f931626fa15460566b8d59359b041bc2eb55d2e 100644 (file)
   <!-- generated index should go. -->
 
   <xsl:if test="count(*)>0 or $generate.index != '0'">
-    <xsl:variable name="id">
-      <xsl:call-template name="object.id"/>
-    </xsl:variable>
-
-    <div id="{$id}" class="{name(.)}">
+    <div class="{name(.)}">
+      <xsl:call-template name="anchor"/>
       <xsl:call-template name="index.titlepage"/>
       <xsl:apply-templates/>
 
 <xsl:template match="index/titleabbrev"></xsl:template>
 
 <xsl:template match="index/title" mode="component.title.mode">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select=".."/>
-    </xsl:call-template>
-  </xsl:variable>
   <h2 class="title">
-    <a name="{$id}">
-      <xsl:apply-templates/>
-    </a>
+    <xsl:apply-templates/>
   </h2>
 </xsl:template>
 
@@ -66,6 +56,7 @@
 
 <xsl:template match="indexdiv">
   <div class="{name(.)}">
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates mode="not-indexentrys"/>
     <dl>
       <xsl:apply-templates select="indexentry"/>
 </xsl:template>
 
 <xsl:template match="indexdiv/title">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select=".."/>
-    </xsl:call-template>
-  </xsl:variable>
   <h3 class="{name(.)}">
-    <a name="{$id}">
-      <xsl:apply-templates/>
-    </a>
+    <xsl:apply-templates/>
   </h3>
 </xsl:template>
 
 <!-- ==================================================================== -->
 
 <xsl:template match="indexterm">
+  <!-- this one must have a name, even if it doesn't have an ID -->
   <xsl:variable name="id">
     <xsl:call-template name="object.id"/>
   </xsl:variable>
index 5d15b01a2495b29e68bd5020630c3e7ca792bbf3..1635d5188801bc82d96bb6de4326f12adf2bbb86 100644 (file)
@@ -14,9 +14,7 @@
 
 <xsl:template name="inline.charseq">
   <xsl:param name="content">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </xsl:param>
   <xsl:copy-of select="$content"/>
@@ -24,9 +22,7 @@
 
 <xsl:template name="inline.monoseq">
   <xsl:param name="content">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </xsl:param>
   <tt><xsl:copy-of select="$content"/></tt>
@@ -34,9 +30,7 @@
 
 <xsl:template name="inline.boldseq">
   <xsl:param name="content">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </xsl:param>
   <!-- don't put <b> inside figure, example, or table titles -->
@@ -55,9 +49,7 @@
 
 <xsl:template name="inline.italicseq">
   <xsl:param name="content">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </xsl:param>
   <i><xsl:copy-of select="$content"/></i>
@@ -65,9 +57,7 @@
 
 <xsl:template name="inline.boldmonoseq">
   <xsl:param name="content">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </xsl:param>
   <!-- don't put <b> inside figure, example, or table titles -->
@@ -88,9 +78,7 @@
 
 <xsl:template name="inline.italicmonoseq">
   <xsl:param name="content">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </xsl:param>
   <i><tt><xsl:copy-of select="$content"/></tt></i>
@@ -98,9 +86,7 @@
 
 <xsl:template name="inline.superscriptseq">
   <xsl:param name="content">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </xsl:param>
   <sup><xsl:copy-of select="$content"/></sup>
 
 <xsl:template name="inline.subscriptseq">
   <xsl:param name="content">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </xsl:param>
   <sub><xsl:copy-of select="$content"/></sub>
         </xsl:attribute>
       </xsl:otherwise>
     </xsl:choose>
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
 
     <xsl:choose>
       <xsl:when test="@role = 'bold'">
         <xsl:value-of select="@role"/>
       </xsl:attribute>
     </xsl:if>
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </span>
 </xsl:template>
index 14b79ee660b056710634fc148ebf7bfbe57b9c4b..338b23169575e5ab799a4f959b9975a28ee9d8ff 100644 (file)
@@ -16,9 +16,7 @@
 
 <xsl:template match="itemizedlist">
   <div class="{name(.)}">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:if test="title">
       <xsl:apply-templates select="title"/>
     </xsl:if>
@@ -93,9 +91,7 @@
   </xsl:variable>
 
   <div class="{name(.)}">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:if test="title">
       <xsl:apply-templates select="title"/>
     </xsl:if>
 
 <xsl:template match="variablelist">
   <div class="{name(.)}">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:if test="title">
       <xsl:apply-templates select="title"/>
     </xsl:if>
 </xsl:template>
 
 <xsl:template match="listitem">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
   <xsl:variable name="mark" select="ancestor-or-self::*/@mark"/>
   <xsl:variable name="override" select="@override"/>
 
          is a para, assume the para will put in the anchor. Otherwise,
          put the anchor in anyway. -->
     <xsl:if test="local-name(child::*[1]) != 'para'">
-      <a name="{$id}"/>
+      <xsl:call-template name="anchor"/>
     </xsl:if>
 
     <xsl:choose>
   <xsl:choose>
     <xsl:when test="not(preceding-sibling::*)
                     and not (following-sibling::*)">
-      <xsl:if test="@id">
-        <a name="{@id}"/>
-      </xsl:if>
+      <xsl:call-template name="anchor"/>
       <xsl:apply-templates/>
     </xsl:when>
     <xsl:otherwise>
       <p>
-        <xsl:if test="@id">
-          <a name="{@id}"/>
-        </xsl:if>
+        <xsl:call-template name="anchor"/>
         <xsl:apply-templates/>
       </p>
     </xsl:otherwise>
 </xsl:template>
 
 <xsl:template match="varlistentry">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-  <dt><a name="{$id}"/><xsl:apply-templates select="term"/></dt>
-  <dd><xsl:apply-templates select="listitem"/></dd>
+  <dt>
+    <xsl:call-template name="anchor"/>
+    <xsl:apply-templates select="term"/>
+  </dt>
+  <dd>
+    <xsl:apply-templates select="listitem"/>
+  </dd>
 </xsl:template>
 
 <xsl:template match="varlistentry/term">
   <span class="term">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
     <xsl:text>, </xsl:text>
   </span>
 
 <xsl:template match="varlistentry/term[position()=last()]" priority="2">
   <span class="term">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </span>
 </xsl:template>
 
 <xsl:template match="simplelist">
   <!-- with no type specified, the default is 'vert' -->
-  <xsl:if test="@id">
-    <a name="{@id}"/>
-  </xsl:if>
+  <xsl:call-template name="anchor"/>
   <table class="simplelist" border="0" summary="Simple list">
     <xsl:call-template name="simplelist.vert">
       <xsl:with-param name="cols">
 
 <xsl:template match="simplelist[@type='inline']">
   <span class="{name(.)}">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </span>
 </xsl:template>
 
 <xsl:template match="simplelist[@type='horiz']">
-  <xsl:if test="@id">
-    <a name="{@id}"/>
-  </xsl:if>
+  <xsl:call-template name="anchor"/>
   <table class="simplelist" border="0" summary="Simple list">
     <xsl:call-template name="simplelist.horiz">
       <xsl:with-param name="cols">
 </xsl:template>
 
 <xsl:template match="simplelist[@type='vert']">
-  <xsl:if test="@id">
-    <a name="{@id}"/>
-  </xsl:if>
+  <xsl:call-template name="anchor"/>
   <table class="simplelist" border="0" summary="Simple list">
     <xsl:call-template name="simplelist.vert">
       <xsl:with-param name="cols">
 
 <xsl:template match="procedure">
   <div class="{name(.)}">
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:if test="title or $formal.procedures != 0">
       <xsl:call-template name="formal.object.heading"/>
     </xsl:if>
     <xsl:call-template name="procedure.step.numeration"/>
   </xsl:variable>
 
-  <xsl:if test="@id">
-    <a name="{@id}"/>
-  </xsl:if>
+  <xsl:call-template name="anchor"/>
 
   <ol type="{$numeration}">
     <xsl:apply-templates/>
 </xsl:template>
 
 <xsl:template match="step">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <li>
-    <a name="{$id}"/>
+    <xsl:call-template name="anchor"/>
     <xsl:apply-templates/>
   </li>
 </xsl:template>
 <!-- ==================================================================== -->
 
 <xsl:template match="segmentedlist">
-  <xsl:if test="@id">
-    <a name="{@id}"/>
-  </xsl:if>
+  <xsl:call-template name="anchor"/>
   <xsl:apply-templates/>
 </xsl:template>
 
 <!-- ==================================================================== -->
 
 <xsl:template match="calloutlist">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
   <div class="{name(.)}">
-    <a name="{$id}"/>
+    <xsl:call-template name="anchor"/>
     <xsl:if test="./title">
       <p>
         <b>
 </xsl:template>
 
 <xsl:template match="callout">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
   <xsl:choose>
     <xsl:when test="$callout.list.table != 0">
       <tr>
         <td width="5%" valign="top" align="left">
-          <a name="{$id}"/>
+          <xsl:call-template name="anchor"/>
           <xsl:call-template name="callout.arearefs">
             <xsl:with-param name="arearefs" select="@arearefs"/>
           </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
       <dt>
-        <a name="{$id}"/>
+        <xsl:call-template name="anchor"/>
         <xsl:call-template name="callout.arearefs">
           <xsl:with-param name="arearefs" select="@arearefs"/>
         </xsl:call-template>
index 3a031a926321112f6c1a04bc54ab75388c21ce91..1bfbf873cc4d6a8173bf51119939b8509eeccea9 100644 (file)
   <xsl:variable name="qalevel">
     <xsl:call-template name="qandadiv.section.level"/>
   </xsl:variable>
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select="parent::*"/>
-    </xsl:call-template>
-  </xsl:variable>
 
   <xsl:element name="h{string(number($qalevel)+1)}">
     <xsl:attribute name="class">
       <xsl:value-of select="name(.)"/>
     </xsl:attribute>
-    <a name="{$id}"/>
+    <xsl:call-template name="anchor">
+      <xsl:with-param name="node" select=".."/>
+    </xsl:call-template>
     <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
     <xsl:text> </xsl:text>
     <xsl:apply-templates/>
 
   <div class="{name(.)}">
     <p>
-      <xsl:if test="../@id">
-        <a>
-          <xsl:attribute name="name">
-            <xsl:call-template name="object.id">
-              <xsl:with-param name="object" select="parent::*"/>
-            </xsl:call-template>
-          </xsl:attribute>
-        </a>
-      </xsl:if>
-      <a name="{$id}"/>
+      <xsl:call-template name="anchor">
+        <xsl:with-param name="node" select=".."/>
+      </xsl:call-template>
+      <xsl:call-template name="anchor"/>
 
       <xsl:choose>
         <xsl:when test="$deflabel = 'none'">
 <xsl:template match="answer">
   <xsl:variable name="firstch" select="(*[name(.)!='label'])[1]"/>
   <xsl:variable name="restch" select="(*[name(.)!='label'])[position()!=1]"/>
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
 
   <div class="{name(.)}">
     <p>
-      <a name="{$id}"/>
+      <xsl:call-template name="anchor"/>
       <b>
         <xsl:apply-templates select="." mode="label.markup"/>
       </b>
index 8517797786c4be19383927feaed0fabd75e2685e..79e9fab508efd41fa90afcd1187037585eff9ba4 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="reference">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <div class="{name(.)}">
-    <xsl:if test="@id">
-      <a name="{$id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
     <xsl:call-template name="reference.titlepage"/>
     <xsl:if test="not(partintro) and $generate.reference.toc != '0'">
       <xsl:call-template name="division.toc"/>
 
   <div class="{name(.)}">
     <h1 class="title">
-      <a>
-        <xsl:attribute name="name">
-          <xsl:call-template name="object.id"/>
-        </xsl:attribute>
-      </a>
+      <xsl:call-template name="anchor"/>
       <xsl:copy-of select="$title"/>
     </h1>
     <xsl:apply-templates/>
 
 <xsl:template match="refnamediv">
   <div class="{name(.)}">
-    <a>
-      <xsl:attribute name="name">
-        <xsl:call-template name="object.id"/>
-      </xsl:attribute>
-    </a>
+    <xsl:call-template name="anchor"/>
     <xsl:if test="$refentry.generate.name != 0">
       <h2>
         <xsl:call-template name="gentext">
 
 <xsl:template match="refsynopsisdiv">
   <div class="{name(.)}">
-    <a>
-      <xsl:attribute name="name">
-        <xsl:call-template name="object.id"/>
-      </xsl:attribute>
-    </a>
+    <xsl:call-template name="anchor"/>
     <h2>
       <xsl:choose>
         <xsl:when test="refsynopsisdiv/title|title">
index 0a3519fb1e9d3725ee3e2127c1c899b68d59676b..3cbfbc8cf7aa1e9ea952a333ecc6d120a68c5211 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="section">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
   <xsl:variable name="depth" select="count(ancestor::section)+1"/>
 
   <div class="{name(.)}">
-    <a name="{$id}"/>
     <xsl:call-template name="section.titlepage"/>
     <xsl:if test="($generate.section.toc != '0'
                    and $depth &lt;= $generate.section.toc.level)
 </xsl:template>
 
 <xsl:template match="sect1">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <div class="{name(.)}">
-    <a name="{$id}"/>
     <xsl:call-template name="sect1.titlepage"/>
     <xsl:if test="($generate.section.toc != '0'
                    and $generate.section.toc.level &gt;= 1)
 </xsl:template>
 
 <xsl:template match="sect2">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <div class="{name(.)}">
-    <a name="{$id}"/>
     <xsl:call-template name="sect2.titlepage"/>
     <xsl:if test="($generate.section.toc != '0'
                    and $generate.section.toc.level &gt;= 2)
 </xsl:template>
 
 <xsl:template match="sect3">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <div class="{name(.)}">
-    <a name="{$id}"/>
     <xsl:call-template name="sect3.titlepage"/>
     <xsl:if test="($generate.section.toc != '0'
                    and $generate.section.toc.level &gt;= 3)
 </xsl:template>
 
 <xsl:template match="sect4">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <div class="{name(.)}">
-    <a name="{$id}"/>
     <xsl:call-template name="sect4.titlepage"/>
     <xsl:if test="($generate.section.toc != '0'
                    and $generate.section.toc.level &gt;= 4)
 </xsl:template>
 
 <xsl:template match="sect5">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <div class="{name(.)}">
-    <a name="{$id}"/>
     <xsl:call-template name="sect5.titlepage"/>
     <xsl:if test="($generate.section.toc != '0'
                    and $generate.section.toc.level &gt;= 5)
 </xsl:template>
 
 <xsl:template match="simplesect">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <div class="{name(.)}">
-    <a name="{$id}"/>
     <xsl:call-template name="simplesect.titlepage"/>
     <xsl:apply-templates/>
   </div>
   <xsl:param name="section" select="."/>
   <xsl:param name="level" select="'1'"/>
   <xsl:param name="title"/>
+
+  <xsl:variable name="id">
+    <xsl:choose>
+      <!-- if title is in an *info wrapper, get the grandparent -->
+      <xsl:when test="contains(local-name(..), 'info')">
+        <xsl:call-template name="object.id">
+          <xsl:with-param name="object" select="../.."/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="object.id">
+          <xsl:with-param name="object" select=".."/>
+        </xsl:call-template>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
   <xsl:element name="h{$level}">
     <xsl:attribute name="class">title</xsl:attribute>
     <xsl:if test="$css.decoration != '0'">
         <xsl:attribute name="style">clear: both</xsl:attribute>
       </xsl:if>
     </xsl:if>
-    <a>
-      <xsl:attribute name="name">
-        <xsl:call-template name="object.id">
-          <xsl:with-param name="object" select="$section"/>
-        </xsl:call-template>
-      </xsl:attribute>
-    </a>
+    <xsl:call-template name="anchor">
+      <xsl:with-param name="node" select="$section"/>
+      <xsl:with-param name="conditional" select="0"/>
+    </xsl:call-template>
     <xsl:copy-of select="$title"/>
   </xsl:element>
 </xsl:template>
     </xsl:choose>
   </xsl:variable>
 
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
-
   <xsl:element name="h{$level}">
-    <a name="{$id}"/>
+    <xsl:call-template name="anchor">
+      <xsl:with-param name="conditional" select="0"/>
+    </xsl:call-template>
     <xsl:apply-templates/>
   </xsl:element>
 </xsl:template>
index bb4f556e4ae9afbc858078d51c1f4959d07d25ce..ee908a2d4db7d1ba980285f4f5bdb01f682afcfd 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="cmdsynopsis">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
-
-  <div class="{name(.)}" id="{$id}">
+  <div class="{name(.)}">
     <p>
-      <a name="{$id}"/>
+      <xsl:call-template name="anchor"/>
       <xsl:apply-templates/>
     </p>
   </div>
index 8a5fe554873661bf3882f5deca2544f13b02b7b1..13cb7c9fb1ad6ec44e301dcd50bdd5c31324c200 100644 (file)
 
     <xsl:if test="not(preceding-sibling::*)
                   and ancestor::row/@id">
-      <a name="{ancestor::row/@id}"/>
+      <xsl:call-template name="anchor">
+        <xsl:with-param name="node" select="ancestor::row[1]"/>
+      </xsl:call-template>
     </xsl:if>
 
-    <xsl:if test="@id">
-      <a name="{@id}"/>
-    </xsl:if>
+    <xsl:call-template name="anchor"/>
 
     <xsl:choose>
       <xsl:when test="$empty.cell">
index a3f6b7314b9e8fc739d7c51ff8115bea0e646b91..2f871cc59cf9112f61719a43fdbeca97ae690383 100644 (file)
@@ -24,9 +24,7 @@
   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
   <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
 
-  <xsl:if test="@id">
-    <a href="{$id}"/>
-  </xsl:if>
+  <xsl:call-template name="anchor"/>
 
   <xsl:variable name="content">
     <xsl:choose>
index a47bf28239580b35010fcd5b0b75f42e5dda28ab..d15d3cd46c96a830af446c0f177471f30d0863d6 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="anchor">
-  <a>
-    <xsl:attribute name="name">
-      <xsl:call-template name="object.id"/>
-    </xsl:attribute>
-  </a>
+  <xsl:call-template name="anchor"/>
 </xsl:template>
 
 <!-- ==================================================================== -->
@@ -35,9 +31,7 @@
     <xsl:with-param name="linkend" select="@linkend"/>
   </xsl:call-template>
 
-  <xsl:if test="@id">
-    <a name="{@id}"/>
-  </xsl:if>
+  <xsl:call-template name="anchor"/>
 
   <xsl:choose>
     <xsl:when test="count($target) = 0">
 </xsl:template>
 
 <xsl:template match="olink">
-  <xsl:if test="@id">
-    <a name="{@id}"/>
-  </xsl:if>
-
+  <xsl:call-template name="anchor"/>
   <xsl:variable name="localinfo" select="@localinfo"/>
 
   <xsl:variable name="href">