If subsection name is not unique, prefix the anchor name with the name of section...
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 4 Mar 2010 09:47:35 +0000 (09:47 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 4 Mar 2010 09:47:35 +0000 (09:47 +0000)
This is especially useful for the Tomcat configuration docs, where names such as "Introduction" or "Attributes" are not unique. See e.g.
config/filter.html
config/valve.html

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@918914 13f79535-47bb-0310-9956-ffa450edef68

webapps/docs/tomcat-docs.xsl

index 85fec75..c3b05ca 100644 (file)
   <!-- Process a documentation subsection -->
   <xsl:template match="subsection">
     <xsl:variable name="name">
+      <xsl:if test="
+          count(//*[(local-name()='section' or local-name()='subsection') and @name=current()/@name]) &gt; 1
+          ">
+        <xsl:value-of select="concat(ancestor::section/@name, '/')"/>
+      </xsl:if>
       <xsl:value-of select="@name"/>
     </xsl:variable>
     <table border="0" cellspacing="0" cellpadding="2">
 
   <xsl:template mode="toc" match="section|subsection">
     <xsl:variable name="name">
+      <xsl:if test="local-name()='subsection' and 
+          count(//*[(local-name()='section' or local-name()='subsection') and @name=current()/@name]) &gt; 1
+          ">
+        <xsl:value-of select="concat(ancestor::section/@name, '/')"/>
+      </xsl:if>
       <xsl:value-of select="@name"/>
     </xsl:variable>
     <li><a href="#{$name}"><xsl:value-of select="@name"/></a>