More anchor handling improvements:
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 May 2010 20:13:30 +0000 (20:13 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 May 2010 20:13:30 +0000 (20:13 +0000)
1) escape '#' character as well as spaces. See virtual-hosting-howto.html for an example.
2) allow to explicitly specify anchor name, using anchor="" attribute on a (sub)section. See default-servlet.html for an example.

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

webapps/docs/default-servlet.xml
webapps/docs/tomcat-docs.xsl

index 9f6c92d..1107f3f 100644 (file)
 <toc/>
 </section>
 
-<section name="What is the DefaultServlet">
-<a name="what"></a>
+<section anchor="what" name="What is the DefaultServlet">
 The default servlet is the servlet which serves static resources as well
 as serves the directory listings (if directory listings are enabled).
 
 </section>
 
-<section name="Where is it declared?">
-<a name="where"></a>
+<section anchor="where" name="Where is it declared?">
 It is declared globally in <i>$CATALINA_BASE/conf/web.xml</i>.
 By default here is it's declaration:
 <source>
@@ -74,8 +72,7 @@ So by default, the default servlet is loaded at webapp startup and
 directory listings are enabled and debugging is turned off.
 </section>
 
-<section name="What can I change?">
-<a name="change"></a>
+<section anchor="change" name="What can I change?">
 The DefaultServlet allows the following initParamters:
 
 <table border="1">
@@ -194,8 +191,7 @@ The DefaultServlet allows the following initParamters:
 </table>
 </section>
 
-<section name="How do I customize directory listings?">
-<a name="dir"></a>
+<section anchor="dir" name="How do I customize directory listings?">
 <p>You can override DefaultServlet with you own implementation and use that
 in your web.xml declaration. If you
 can understand what was just said, we will assume you can read the code
@@ -313,8 +309,7 @@ The following is a sample xsl file which mimics the default tomcat behavior:
 
 </section>
 
-<section name="How do I secure directory listings?">
-<a name="secure"></a>
+<section anchor="secure" name="How do I secure directory listings?">
 Use web.xml in each individual webapp. See the security section of the
 Servlet specification.
 
index 7497c43..569fdb0 100644 (file)
   <!-- Process a documentation section -->
   <xsl:template match="section">
     <xsl:variable name="name">
-      <xsl:value-of select="@name"/>
+      <xsl:choose>
+        <xsl:when test="@anchor">
+          <xsl:value-of select="@anchor" />
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="@name"/>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:variable>
     <xsl:variable name="name2">
-      <xsl:value-of select="translate($name, ' ', '_')"/>
+      <xsl:value-of select="translate($name, ' #', '__')"/>
     </xsl:variable>
     <table border="0" cellspacing="0" cellpadding="2">
       <!-- Section heading -->
   <!-- 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:choose>
+        <xsl:when test="@anchor">
+          <xsl:value-of select="@anchor" />
+        </xsl:when>
+        <xsl:otherwise>
+          <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:otherwise>
+      </xsl:choose>
     </xsl:variable>
     <xsl:variable name="name2">
-      <xsl:value-of select="translate($name, ' ', '_')"/>
+      <xsl:value-of select="translate($name, ' #', '__')"/>
     </xsl:variable>
     <table border="0" cellspacing="0" cellpadding="2">
       <!-- Subsection heading -->
 
   <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:choose>
+        <xsl:when test="@anchor">
+          <xsl:value-of select="@anchor" />
+        </xsl:when>
+        <xsl:otherwise>
+          <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:otherwise>
+      </xsl:choose>
     </xsl:variable>
     <xsl:variable name="name2">
-      <xsl:value-of select="translate($name, ' ', '_')"/>
+      <xsl:value-of select="translate($name, ' #', '__')"/>
     </xsl:variable>
     <li><a href="#{$name2}"><xsl:value-of select="@name"/></a>
     <xsl:if test="subsection">