morgand     01/08/06 15:05:43

  Modified:    src/taglib taglib-doc.xsl
  Log:
  added documentation elements, added ability to load certain elements from
  external URIs, provided logical defaults for some optional elements
  
  Revision  Changes    Path
  1.9       +183 -86   jakarta-taglibs/src/taglib/taglib-doc.xsl
  
  Index: taglib-doc.xsl
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/src/taglib/taglib-doc.xsl,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- taglib-doc.xsl    2001/07/13 00:30:45     1.8
  +++ taglib-doc.xsl    2001/08/06 22:05:43     1.9
  @@ -74,22 +74,27 @@
   
     <!-- Table of Contents -->
     <h3>Table of Contents</h3>
  -  <a href="#overview">Overview</a><br/>
  -  <a href="#requirements">Requirements</a><br/>
  -  <a href="#config">Configuration</a><br/>
  -  <a href="#summary">Tag Summary</a><br/>
  -  <a href="#reference">Tag Reference</a><br/>
  -  <!-- Additional TOC sections -->
  -  <xsl:for-each select="toc">
  -    <a>
  -      <xsl:attribute name="href">#<xsl:value-of select="@href"/>
  -      </xsl:attribute><xsl:value-of select="@name"/>
  -    </a><br/>
  -  </xsl:for-each>
  -  <!-- End Additional TOC sections -->
  -  <a href="#examples">Examples</a><br/>
  -  <a href="#javadocs">Javadocs</a><br/>
  -  <a href="#history">Revision History</a><br/>    
  +  <ul>
  +    <li><a href="#overview">Overview</a></li>
  +    <li><a href="#requirements">Requirements</a></li>
  +    <li><a href="#config">Configuration</a></li>
  +    <xsl:call-template name="doctoc"/>
  +    <li><a href="#summary">Tag Summary</a></li>
  +    <li><a href="#reference">Tag Reference</a></li>
  +    <!-- Additional TOC sections, the toc element is undocumented -->
  +    <xsl:for-each select="toc">
  +      <li>
  +        <a>
  +          <xsl:attribute name="href">#<xsl:value-of select="@href"/>
  +          </xsl:attribute><xsl:value-of select="@name"/>
  +        </a>
  +      </li>
  +    </xsl:for-each>
  +    <!-- End Additional TOC sections -->
  +    <li><a href="#examples">Examples</a></li>
  +    <li><a href="#javadocs">Javadocs</a></li>
  +    <li><a href="#history">Revision History</a></li>
  +  </ul>    
   
     <!-- Overview -->
     <a><xsl:attribute name="name">overview</xsl:attribute></a>
  @@ -102,33 +107,10 @@
     <xsl:apply-templates select="requirements-info"/>
   
     <!-- Configuration -->
  -  <a><xsl:attribute name="name">config</xsl:attribute></a>
  -  <h3>Configuration</h3>
  -  <p>Follow these steps to configure your web application with this tag
  -     library:</p>
  -  <ul>
  -    <li>Copy the tag library descriptor file to the /WEB-INF subdirectory
  -        of your web application.</li>
  -    <li>Copy the tag library JAR file to the /WEB-INF/lib subdirectory 
  -        of your web application.</li>
  -    <li>Add a &lt;taglib&gt; element to your web application deployment
  -        descriptor in /WEB-INF/web.xml like this:
  -<pre>
  -&lt;taglib&gt;
  -  &lt;taglib-uri&gt;http://jakarta.apache.org/taglibs/<xsl:value-of 
select="short-name"/>-<xsl:value-of select="tlib-version"/>&lt;/taglib-uri&gt;
  -  &lt;taglib-location&gt;<xsl:value-of 
select="taglib-location"/>&lt;/taglib-location&gt;
  -&lt;/taglib&gt;
  -</pre>
  -    </li>
  -  </ul>
  -  <p>To use the tags from this library in your JSP pages, add the following
  -     directive at the top of each page: </p>
  -<pre>
  -&lt;%@ taglib uri=&quot;http://jakarta.apache.org/taglibs/<xsl:value-of 
select="short-name"/>-<xsl:value-of select="tlib-version"/>&quot; 
prefix=&quot;<xsl:value-of select="prefix"/>&quot; %&gt;
  -</pre>
  -  <p>where &quot;<i><xsl:value-of select="prefix"/></i>&quot; is the tag
  -     name prefix you wish to use for tags from this library. You can change
  -     this value to any prefix you like.</p>
  +  <xsl:call-template name="configuration"/>
  +
  +  <!-- Documentation -->
  +  <xsl:call-template name="documentation"/>
   
     <!--  Tag Summary Section  -->
     <a><xsl:attribute name="name">summary</xsl:attribute></a>
  @@ -138,13 +120,22 @@
       <table border="0" width="90%" cellpadding="3" cellspacing="3">
         <xsl:for-each select="tag">
           <tr>
  -          <td width="25%">
  +          <td width="25%" valign="top">
               <a>
                 <xsl:attribute name="href">#<xsl:value-of select="name"/>
                 </xsl:attribute><xsl:value-of select="name"/>
               </a>
  +          </td>
  +          <td width="75%">
  +            <xsl:choose>
  +              <xsl:when test="summary">
  +                <xsl:value-of select="summary"/>
  +              </xsl:when>
  +              <xsl:otherwise>
  +                <xsl:value-of select="description"/>
  +              </xsl:otherwise>
  +            </xsl:choose>
             </td>
  -          <td width="75%"><xsl:value-of select="summary"/></td>
           </tr> 
         </xsl:for-each>
         <!-- The next empty row is for formatting purposes only. -->
  @@ -188,7 +179,16 @@
           </tr>
           <tr>
             <td><b>Restrictions</b></td>
  -          <td colspan="5"><xsl:value-of select="restrictions"/></td>
  +          <td colspan="5">
  +            <xsl:choose>
  +              <xsl:when test="restrictions">
  +                <xsl:value-of select="restrictions"/>
  +              </xsl:when>
  +              <xsl:otherwise>
  +                None
  +              </xsl:otherwise>
  +            </xsl:choose>
  +          </td>
           </tr>
   
           <!-- BEGIN xsl:choose
  @@ -357,41 +357,7 @@
           <!-- END xsl:choose -->
   
           <!-- Examples Section -->
  -        <xsl:choose>
  -          <xsl:when test="example/usage">
  -            <xsl:for-each select="example/usage">
  -              <tr>
  -                <td><b>Examples</b></td>
  -                <td colspan="5" bgcolor="#cccccc">
  -                  <xsl:if test="comment">
  -                    <xsl:value-of select="comment"/>
  -                  </xsl:if> 
  -                  <xsl:text>&#160;</xsl:text>
  -                </td>
  -              </tr>
  -              <tr>
  -                <td><xsl:text>&#160;</xsl:text></td>
  -                <td colspan="5">
  -                  <xsl:for-each select="scriptlet">
  -                    &lt;%<xsl:value-of select="."/>%&gt;<br/> 
  -                  </xsl:for-each>
  -                  <!-- A little trick here: the XML element <code> in our
  -                       TLDoc matches the HTML element <code> on purpose so
  -                       that we can just copy the whole node, including the
  -                       opening and closing <code> tags.
  -                       -->
  -                  <p><pre><xsl:copy-of select="code"/></pre></p>
  -                </td>
  -              </tr>
  -            </xsl:for-each>
  -          </xsl:when>
  -          <xsl:otherwise>
  -            <tr>
  -              <td><b>Examples</b></td>
  -              <td colspan="5">None</td>
  -            </tr>
  -          </xsl:otherwise>
  -        </xsl:choose>
  +        <xsl:call-template name="examples"/>
           <!-- End Examples Section -->
         
         </table>
  @@ -427,15 +393,146 @@
   </xsl:template>
     
   <xsl:template match="requirements-info">
  -  <p>
  -  <xsl:copy-of select="*|text()"/>  
  -  </p>
  +  <xsl:call-template name="uri"/>
  +</xsl:template>
  +
  +<xsl:template match="description">
  +  <xsl:call-template name="uri"/>
   </xsl:template>
   
  -<xsl:template match="description">  
  -  <xsl:copy-of select="*|text()"/>
  +<xsl:template match="docs">
  +  <xsl:call-template name="uri"/>
   </xsl:template>
   
  +<xsl:template name="uri">
  +  <xsl:choose>
  +    <xsl:when test="@uri">
  +      <xsl:copy-of select="document(@uri)"/>
  +    </xsl:when>
  +    <xsl:otherwise>
  +      <p>
  +        <xsl:copy-of select="*|text()"/>  
  +      </p>
  +    </xsl:otherwise>
  +  </xsl:choose>
  +</xsl:template>
  +       
   <xsl:template match="/document/revision"/>
   
  +<xsl:template name="documentation">
  +  <xsl:if test="documentation">
  +    <a><xsl:attribute name="name">documentation</xsl:attribute></a>
  +    <h3>Documentation</h3>
  +    <xsl:apply-templates select="documentation/docs"/>
  +  </xsl:if>
  +</xsl:template>
  +
  +<xsl:template name="doctoc">
  +
  +  <xsl:if test="documentation">
  +    <li><a href="#documentation">Documentation</a></li>
  +  </xsl:if>
  +
  +  <xsl:if test="documentation/doctoc">
  +    <ul><xsl:apply-templates select="documentation/doctoc"/></ul>
  +  </xsl:if>
  +</xsl:template>
  +
  +<xsl:template match="li">
  +  <li>
  +
  +  <xsl:choose>
  +    <xsl:when test="@anchor">
  +      <a>
  +        <xsl:attribute name="href">#<xsl:value-of select="@anchor"/></xsl:attribute>
  +        <xsl:apply-templates/>
  +      </a>
  +    </xsl:when>
  +    <xsl:otherwise>
  +      <xsl:apply-templates/>
  +    </xsl:otherwise>
  +  </xsl:choose>
  +
  +  </li>
  +</xsl:template>
  +
  +<xsl:template match="ul">
  +  <ul>
  +    <xsl:apply-templates/>
  +  </ul>
  +</xsl:template>
  +
  +<xsl:template name="examples">
  +  <xsl:choose>
  +    <xsl:when test="example">
  +      <xsl:apply-templates select="example"/>
  +    </xsl:when>
  +    <xsl:otherwise>
  +      <tr>
  +        <td><b>Examples</b></td>
  +        <td colspan="5">None</td>
  +      </tr>
  +    </xsl:otherwise>
  +  </xsl:choose>
  +</xsl:template>
  +
  +<xsl:template match="usage">
  +  <tr>
  +    <!-- not sure why it's 2 and not 1  :) -->
  +    <td><xsl:if test="position() = 2"><b>Examples</b></xsl:if></td>
  +    <xsl:if test="comment">
  +      <td colspan="5" bgcolor="#cccccc">
  +        <xsl:value-of select="comment"/>
  +        <xsl:text>&#160;</xsl:text>
  +      </td>
  +    </xsl:if>
  +  </tr>
  +
  +  <tr>
  +    <td><xsl:text>&#160;</xsl:text></td>
  +    <td colspan="5">
  +      <xsl:for-each select="scriptlet">
  +        &lt;%<xsl:value-of select="."/>%&gt;<br/> 
  +      </xsl:for-each>
  +      <!-- A little trick here: the XML element <code> in our
  +           TLDoc matches the HTML element <code> on purpose so
  +           that we can just copy the whole node, including the
  +           opening and closing <code> tags.
  +           -->
  +      <p><pre><xsl:copy-of select="code"/></pre></p>
  +    </td>
  +  </tr> 
  +</xsl:template>
  +
  +<xsl:template name="configuration">
  +  <a><xsl:attribute name="name">config</xsl:attribute></a>
  +  <h3>Configuration</h3>
  +  <p>Follow these steps to configure your web application with this tag
  +     library:</p>
  +  <ul>
  +    <li>Copy the tag library descriptor file to the /WEB-INF subdirectory
  +        of your web application.</li>
  +    <li>Copy the tag library JAR file to the /WEB-INF/lib subdirectory 
  +        of your web application.</li>
  +    <li>Add a &lt;taglib&gt; element to your web application deployment
  +        descriptor in /WEB-INF/web.xml like this:
  +<pre>
  +&lt;taglib&gt;
  +  &lt;taglib-uri&gt;http://jakarta.apache.org/taglibs/<xsl:value-of 
select="short-name"/>-<xsl:value-of select="tlib-version"/>&lt;/taglib-uri&gt;
  +  &lt;taglib-location&gt;<xsl:value-of 
select="taglib-location"/>&lt;/taglib-location&gt;
  +&lt;/taglib&gt;
  +</pre>
  +    </li>
  +  </ul>
  +  <p>To use the tags from this library in your JSP pages, add the following
  +     directive at the top of each page: </p>
  +<pre>
  +&lt;%@ taglib uri=&quot;http://jakarta.apache.org/taglibs/<xsl:value-of 
select="short-name"/>-<xsl:value-of select="tlib-version"/>&quot; 
prefix=&quot;<xsl:value-of select="prefix"/>&quot; %&gt;
  +</pre>
  +  <p>where &quot;<i><xsl:value-of select="prefix"/></i>&quot; is the tag
  +     name prefix you wish to use for tags from this library. You can change
  +     this value to any prefix you like.</p>
  +</xsl:template>
  +
   </xsl:stylesheet>
  +
  
  
  

Reply via email to