You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/02/02 07:19:05 UTC

cvs commit: jakarta-tomcat/src/build XMLDoclet.java generateModules.xsl

costin      01/02/01 22:19:04

  Added:       src/build XMLDoclet.java generateModules.xsl
  Log:
  Temporary add of XMLDoclet, it'll be used to synchronize
  the documentation of modules with the sources ( we may need
  to customize a bit XMLDoclet and add a way to separate between
  "user" doc and technical details ).
  
  Also, added the first version of a stylesheet that will generate
  modules.xml - containing info about modules ( to be used by
  config tools ).
  
  The first use will be to allow a simpler syntax in server.xml
  ( and more familiar to most people )
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat/src/build/XMLDoclet.java
  
  Index: XMLDoclet.java
  ===================================================================
  /*
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Cocoon" and  "Apache Software Foundation"  must not be used to
      endorse  or promote  products derived  from this  software without  prior
      written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Gopinath M.R. <go...@aztec.soft.net>. For more information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
   */
  
  //package org.apache.tools.doclet.xml;
  
  import java.io.*;
  import java.util.*;
  import com.sun.javadoc.*;
  
  import org.xml.sax.*;
  import org.xml.sax.helpers.*;
  
  import javax.xml.transform.*;
  import javax.xml.transform.stream.*;
  import javax.xml.transform.sax.*;
  
  // Based on the Alexandria project - with experimental changes.
  // Will be contributed back when ready.
  
  /**
   * Main Doclet class to generate JavaDocXML.  This doclet generates the
   * document conforming to DTD specified in javadoc-v04draft.dtd.
   * @author <a href="mailto:gopi@aztecsoft.com">Gopinath M.R.</a>
   */
  public class XMLDoclet extends Doclet {
  
      private String xmlns = "jvx";
      private String encodingFormat="UTF-8";
      private String localName = "javadoc";
      private ContentHandler cm = null;
      private String targetFileName="simple.xml";
      private Attributes emptyAtts = new AttributesImpl();
  
      public XMLDoclet (RootDoc root) throws Exception {
  	String params[][]=root.options();
  	for(int i=0; i<params.length; i++) {
  	    if( params[i].length > 0 &&
  		"-file".equals( params[i][0] )) {
  		targetFileName=params[i][1];
  		System.out.println("Output file " + targetFileName);
  	    }
  	}
  
  	FileWriter writer = new FileWriter(targetFileName);
          try {
  	    TransformerFactory fact=TransformerFactory.newInstance();
  	    if( ! (fact instanceof SAXTransformerFactory) )
  		throw new Exception( "Not a SAXTransformerFactory");
  
  	    SAXTransformerFactory sfact=(SAXTransformerFactory)fact;
  	    // identity transform
  	    TransformerHandler th=sfact.newTransformerHandler();
  	    th.setResult( new StreamResult( writer ));
  
  	    Transformer idT=th.getTransformer();
  	    idT.setOutputProperty( "method", "xml" );
  	    idT.setOutputProperty( "indent", "yes" );
  // 	    idT.setOutputProperty( "doctype-public",
  // 				   "-//APACHE//DTD JavaDoc V0.4//EN");
  // 	    idT.setOutputProperty( "doctype-system",
  // 				   "javadoc-v04draft.dtd" );
  
  	    // Xalan-specific
  	    idT.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount",
  				   "4");
  	    
  	    cm=(ContentHandler)th;
  
  	    cm.startDocument();
  	    
              javadocXML(root);
  
  	    cm.endDocument();
              writer.close();
          } catch (IOException e) {
              writer.close();
              throw e;
          }
      }
  
      public static int optionLength(String option) {
  	if( option.equals("-file" ) ) {
  	    return 2;
  	}
  	return 0;
      }
      
      /**
       * Generates the xml data for the top element.
       * <xmp><!ELEMENT javadoc (package*, class*, interface*)></xmp>
       */
      private void javadocXML(RootDoc root) throws SAXException {
          cm.startElement(xmlns, localName, "javadoc", emptyAtts);
          PackageDoc[] packageArray = root.specifiedPackages();
  
          // Generate for packages.
          for (int i = 0; i < packageArray.length; ++i) {
              packageXML(packageArray[i]);
          }
  
          // Generate for classes.
          ClassDoc[] classArray = root.specifiedClasses();
          Vector interfaceVector = new Vector();
          for (int i = 0; i < classArray.length; ++i) {
              if (classArray[i].isInterface()) {
                  interfaceVector.addElement(classArray[i]);
              } else {
                  classXML(classArray[i]);
              }
          }
  
          // Generate for interfaces.
          Enumeration interfaceEnum = interfaceVector.elements();
          if (interfaceEnum.hasMoreElements()) {
              ClassDoc interfaceDoc = (ClassDoc)interfaceEnum.nextElement();
              interfaceXML(interfaceDoc);
          }
          cm.endElement(xmlns, localName, "javadoc");
      }
  
      /**
       * Generates doc for "package".
       * <xmp><!ELEMENT package (doc?, package*, class*, interface*)>
       *<!ATTLIST package
       *              name CDATA #REQUIRED></xmp>
       */
      private void packageXML(PackageDoc packageDoc) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute(xmlns, localName, "name", "String", packageDoc.name());
          cm.startElement(xmlns, localName, "package", atts);
  
          // generate Doc element.
          docXML(packageDoc);
  
          // TODO:generate Package elements.
          // doubt: How package can exist inside a package?
  
          /* Generate for classes. */
          // for ordinary classes.
          ClassDoc[] classArray = packageDoc.ordinaryClasses();
          for (int i = 0; i < classArray.length; ++i) {
              classXML(classArray[i]);
          }
          // for Exception classes.
          classArray = packageDoc.exceptions();
          for (int i = 0; i < classArray.length; ++i) {
              classXML(classArray[i]);
          }
          // for Error classes
          classArray = packageDoc.errors();
          for (int i = 0; i < classArray.length; ++i) {
              classXML(classArray[i]);
          }
  
          /* Generate for interfaces. */
          ClassDoc[] interfaceArray = packageDoc.interfaces();
          for (int i = 0; i < interfaceArray.length; ++i) {
              interfaceXML(interfaceArray[i]);
          }
  
          cm.endElement(xmlns, localName, "package");
      }
  
      /**
       * Generates doc for element "class".
       * <xmp> <!ELEMENT class (doc?,
       *                  extends_class?,
       *                  implements?,
       *                  constructor*,
       *                  method*,
       *                  innerclass*)>
       * <!ATTLIST class
       *     %name;
       *     %extensibility;
       *     %class.access;></xmp>
       */
      private void classXML(ClassDoc classDoc) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute(xmlns, localName, "name", "String", classDoc.name());
  
          String extensibility = "default";
          if (classDoc.isAbstract()) {
              extensibility = "abstract";
          } else if (classDoc.isFinal()) {
              extensibility = "final";
          }
          atts.addAttribute(xmlns, localName, "extensiblity", "String", extensibility);
          String access = "package";
          if (classDoc.isPublic()) {
              access = "public";
          }
          atts.addAttribute(xmlns, localName, "access", "String", access);
          cm.startElement(xmlns, localName, "class", atts);
  
          // generate "doc" sub-element
          docXML(classDoc);
  
          // generate "extends_class" sub-element
          extendsXML(classDoc);
  
          // generate "implements" sub-element
          implementsXML(classDoc);
  
          // generate "field" sub-elements
          FieldDoc[] fieldArray = classDoc.fields();
          for (int i = 0; i < fieldArray.length; ++i) {
              fieldXML(fieldArray[i]);
          }
  
          // generate "constructor" sub-elements
          ConstructorDoc[] constructorArray = classDoc.constructors();
          for (int i = 0; i < constructorArray.length; ++i) {
              constructorXML(constructorArray[i]);
          }
  
          // generate "method" sub-elements
          MethodDoc[] methodArray = classDoc.methods();
          for (int i = 0; i < methodArray.length; ++i) {
              methodXML(methodArray[i]);
          }
  
          // generate "innerclass" sub-elements
          ClassDoc[] innerClassArray = classDoc.innerClasses();
          for (int i = 0; i < innerClassArray.length; ++i) {
              innerClassXML(innerClassArray[i]);
          }
  
          cm.endElement(xmlns, localName, "class");
      }
  
      /**
       * Generates doc for element "extends_class"
       * <xmp><!ELEMENT extends_class (classref+)></xmp>
       */
      private void extendsXML(ClassDoc classDoc) throws SAXException {
          if (classDoc.superclass() != null) {
              cm.startElement(xmlns, localName, "extends_class", emptyAtts);
              createRefXML("classref", classDoc.superclass().qualifiedName());
              cm.endElement(xmlns, localName, "extends_class");
          }
      }
  
      /**
       * Generates doc for element "innerclass"
       * <xmp> <!ELEMENT innerclass (doc?,
       *                 extends?,
       *                 implements?,
       *                 field*,
       *                 constructor*,
       *                 method*)>
       * <!ATTLIST innerclass
       *    %name;
       *    %access;
       *    %abstract;
       *    %anonymous;
       *    %final;
       *    %static;></xmp>
       */
      private void innerClassXML(ClassDoc classDoc) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute(xmlns, localName, "name", "String", classDoc.name());
          String access = "package";
          if (classDoc.isPublic()) {
              access = "public";
          }
          atts.addAttribute(xmlns, localName, "access", "String", access);
          atts.addAttribute(xmlns, localName, "abstract", "String", ""+ classDoc.isAbstract());
          String anonymous = "false";
          if (classDoc.name().equals("")) {
              anonymous = "true";
          }
          atts.addAttribute(xmlns, localName, "anonymous", "String", ""+ anonymous);
          atts.addAttribute(xmlns, localName, "final", "String", ""+ "" + classDoc.isFinal());
          atts.addAttribute(xmlns, localName, "static", "String", ""+ "" + classDoc.isStatic());
          cm.startElement(xmlns, localName, "innerclass", atts);
  
          // generate "doc" sub-element
          docXML(classDoc);
  
          // generate "extends" sub-element
          extendsXML(classDoc);
  
          // generate "implements" sub-element
          implementsXML(classDoc);
  
          // generate "field" sub-elements
          FieldDoc[] fieldArray = classDoc.fields();
          for (int i = 0; i < fieldArray.length; ++i) {
              fieldXML(fieldArray[i]);
          }
  
          // generate "constructor" sub-elements
          ConstructorDoc[] constructorArray = classDoc.constructors();
          for (int i = 0; i < constructorArray.length; ++i) {
              constructorXML(constructorArray[i]);
          }
  
          // generate "method" sub-elements
          MethodDoc[] methodArray = classDoc.methods();
          for (int i = 0; i < methodArray.length; ++i) {
              methodXML(methodArray[i]);
          }
  
          cm.endElement(xmlns, localName,"innerclass");
      }
  
      /**
       * Generates doc for element "interface"
       * <xmp><!ELEMENT interface (doc?,
       *               extends_interface?,
       *               field*,
       *               method*)>
       * <!ATTLIST interface
       *             %name;
       *             %access;></xmp>
       */
      private void interfaceXML(ClassDoc interfaceDoc) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute(xmlns, localName, "name", "String", interfaceDoc.name());
          String access = "package";
          if (interfaceDoc.isPublic()) {
              access = "public";
          }
          atts.addAttribute(xmlns, localName, "access", "String", access);
          cm.startElement(xmlns, localName, "interface", atts);
  
          // generate "doc" sub-element
          docXML(interfaceDoc);
  
          // generate "extends_interface"
          extends_interfaceXML(interfaceDoc);
  
          // generate "field" sub-elements
          FieldDoc[] fieldArray = interfaceDoc.fields();
          for (int i = 0; i < fieldArray.length; ++i) {
              fieldXML(fieldArray[i]);
          }
  
          // generate "method" sub-elements
          MethodDoc[] methodArray = interfaceDoc.methods();
          for (int i = 0; i < methodArray.length; ++i) {
              methodXML(methodArray[i]);
          }
          cm.endElement(xmlns, localName, "interface");
      }
  
      /**
       * Generates doc for element "extends_interface"
       * <xmp><!ELEMENT extends_interface (interfaceref+)></xmp>
       */
      private void extends_interfaceXML(ClassDoc interfaceDoc) throws SAXException {
          ClassDoc[] interfaceArray = interfaceDoc.interfaces();
          if (interfaceArray.length > 0) {
              cm.startElement(xmlns, localName, "extends_interface", emptyAtts);
              for (int i = 0; i < interfaceArray.length; ++i) {
                  createRefXML("interfaceref", interfaceArray[i].qualifiedName());
              }
              cm.endElement(xmlns, localName, "extends_interface");
          }
      }
  
      /**
       * Generates doc for element "implements"
       * <xmp><!ELEMENT implements (interfaceref+)></xmp>
       */
      private void implementsXML(ClassDoc classDoc) throws SAXException {
          ClassDoc[] interfaceArray = classDoc.interfaces();
          if (interfaceArray.length > 0) {
              cm.startElement(xmlns, localName, "implements", emptyAtts);
              for (int i = 0; i < interfaceArray.length; ++i) {
                  createRefXML("interfaceref", interfaceArray[i].qualifiedName());
              }
              cm.endElement(xmlns, localName, "implements");
          }
      }
  
      /**
       * Generates doc for element "throws"
       * <xmp><!ELEMENT throws (classref)+></xmp>
       */
      private void throwsXML(ExecutableMemberDoc member) throws SAXException {
          ThrowsTag[] tagArray = member.throwsTags();
          if(tagArray.length > 0) {
              cm.startElement(xmlns, localName, "throws", emptyAtts);
              for (int i = 0; i < tagArray.length; ++i) {
                  ClassDoc exceptionClass = tagArray[i].exception();
                  String name = null;
                  if (exceptionClass == null) {
                      name = tagArray[i].exceptionName();
                  } else {
                      name = tagArray[i].exception().qualifiedName();
                  }
                  createRefXML("classref", name);
              }
              cm.endElement(xmlns, localName, "throws");
          }
      }
  
      /**
       * Generates doc for following elements
       * <xmp> <!ELEMENT classref EMPTY>
       * <!ATTLIST classref %name;>
       * <!ELEMENT interfaceref EMPTY>
       * <!ATTLIST interfaceref %name;>
       * <!ELEMENT methodref EMPTY>
       * <!ATTLIST methodref %name;>
       * <!ELEMENT packageref EMPTY>
       * <!ATTLIST packageref %name;></xmp>
       */
      private void createRefXML(String elementName, String nameValue) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute(xmlns, localName, "name", "String", nameValue);
          cm.startElement(xmlns, localName, elementName, atts);
          cm.endElement(xmlns, localName, elementName);
      }
  
      /**
       * Generates doc for "(classref|interfaceref|primitive)" sub-element
       */
      private void createTypeRef(Type type) throws SAXException {
          String qualifiedName = type.qualifiedTypeName();
          ClassDoc fieldType = type.asClassDoc();
          if (fieldType == null) {
              // primitive data type
              AttributesImpl subElmAtts = new AttributesImpl();
              subElmAtts.addAttribute(xmlns, localName, "type", "String", qualifiedName);
              cm.startElement(xmlns, localName, "primitive", subElmAtts);
              cm.endElement(xmlns, localName, "primitive");
          } else if (fieldType.isInterface()) {
              // interface
              createRefXML("interfaceref", qualifiedName);
          } else {
              // class
              createRefXML("classref", qualifiedName);
          }
      }
  
      /**
       * Generates doc for element "field"
       * <xmp> <!ELEMENT field (doc?, (classref | interfaceref | primitive))>
       * <!ATTLIST field
       *    %name;
       *    %access;
       *    %dimension;
       *    %synthetic;
       *    %static;
       *    %final;
       *    %transient;
       *    %volatile;></xmp>
       */
      private void fieldXML(FieldDoc field) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
  
          atts.addAttribute(xmlns, localName, "name", "String", field.name());
  
          String access = "package";
          if (field.isPrivate()) {
              access = "private";
          } else if (field.isProtected()) {
              access = "protected";
          } else if (field.isPublic()) {
              access = "public";
          }
          atts.addAttribute(xmlns, localName, "access", "String", access);
  
          atts.addAttribute(xmlns, localName, "dimension", "String", field.type().dimension());
          atts.addAttribute(xmlns, localName, "synthetic", "String", "" + field.isSynthetic());
          atts.addAttribute(xmlns, localName, "static", "String", "" + field.isStatic());
          atts.addAttribute(xmlns, localName, "final", "String", "" + field.isFinal());
          atts.addAttribute(xmlns, localName, "transient", "String", "" + field.isTransient());
          atts.addAttribute(xmlns, localName, "volatile", "String", "" + field.isVolatile());
          cm.startElement(xmlns, localName, "field", atts);
  
          // generate "doc" sub-element
          docXML(field);
  
          // generate "(classref|interfaceref|primitive)" sub-element
          createTypeRef(field.type()); // foo , field.qualifiedName());
  
          cm.endElement(xmlns, localName, "field");
      }
  
      /**
       * Generates doc for element "constructor"
       * <xmp><!ELEMENT constructor (doc?, parameter*, throws*)>
       * <!ATTLIST constructor
       *     %name;
       *     %access;
       *     %synthetic;></xmp>
       */
      private void constructorXML(ConstructorDoc constrDoc) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute(xmlns, localName, "name", "String", constrDoc.qualifiedName());
          String access = "package";
          if (constrDoc.isPrivate()) {
              access = "private";
          } else if (constrDoc.isProtected()) {
              access = "protected";
          } else if (constrDoc.isPublic()) {
              access = "public";
          }
          atts.addAttribute(xmlns, localName, "access", "String", access);
          atts.addAttribute(xmlns, localName, "synthetic", "String", "" + constrDoc.isSynthetic());
          cm.startElement(xmlns, localName, "constructor", atts);
  
          // generate "doc" sub-element
          docXML(constrDoc);
  
          // generate "parameter" sub-elements
          Parameter[] parameterArray = constrDoc.parameters();
          for (int i = 0; i < parameterArray.length; ++i) {
              parameterXML(parameterArray[i]);
          }
  
          // generate "throws" sub-element
          throwsXML(constrDoc);
  
          cm.endElement(xmlns, localName, "constructor");
      }
  
      /**
       * Generates doc for element "method"
       * <xmp> <!ELEMENT method (doc?, returns, parameter*, throws*)>
       * <!ATTLIST method
       *         %name;
       *         %access;
       *         %extensibility;
       *         %native;
       *         %synthetic;
       *         %static;
       *         %synchronized;></xmp>
       */
      private void methodXML(MethodDoc methodDoc) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          //atts.addAttribute(xmlns, localName, "", String, );
          atts.addAttribute(xmlns, localName, "name", "String", methodDoc.name());
  
          String access = "package";
          if (methodDoc.isPrivate()) {
              access = "private";
          } else if (methodDoc.isProtected()) {
              access = "protected";
          } else if (methodDoc.isPublic()) {
              access = "public";
          }
          atts.addAttribute(xmlns, localName, "access", "String", access);
  
          String extensibility = "default";
          if (methodDoc.isAbstract()) {
              extensibility = "abstract";
          } else if (methodDoc.isFinal()) {
              extensibility = "final";
          }
          atts.addAttribute(xmlns, localName, "extensiblity", "String", extensibility);
  
          atts.addAttribute(xmlns, localName, "native", "String", ""+ methodDoc.isNative());
          atts.addAttribute(xmlns, localName, "synthetic", "String", "" + methodDoc.isSynthetic());
          atts.addAttribute(xmlns, localName, "static", "String", "" + methodDoc.isStatic());
          atts.addAttribute(xmlns, localName, "synchronized", "String", ""+ methodDoc.isSynchronized());
          cm.startElement(xmlns, localName, "method", atts);
  
          // generate "doc" sub-element
          docXML(methodDoc);
  
          // generate "returns" sub-element
          returnsXML(methodDoc.returnType());
  
          // generate "parameter" sub-elements
          Parameter[] parameterArray = methodDoc.parameters();
          for (int i = 0; i < parameterArray.length; ++i) {
              parameterXML(parameterArray[i]);
          }
  
          // generate "throws" sub-element
          throwsXML(methodDoc);
  
          cm.endElement(xmlns, localName, "method");
      }
  
      /**
       * Generates doc for element "returns"
       * <xmp> <!ELEMENT returns (classref | interfaceref | primitive)>
       * <!ATTLIST returns %dimension;></xmp>
       */
      private void returnsXML(Type type) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute(xmlns, localName, "dimension", "String", type.dimension());
          cm.startElement(xmlns, localName, "returns", atts);
  
          // generate "(classref|interfaceref|primitive)" sub-element
          createTypeRef(type);
  
          cm.endElement(xmlns, localName, "returns");
      }
  
      /**
       * Generates doc for element "parameter"
       * <xmp> <!ELEMENT parameter (classref | interfaceref | primitive)>
       * <!ATTLIST parameter
       *         %name;
       *         %final;
       *         %dimension;></xmp>
       */
      private void parameterXML(Parameter parameter) throws SAXException {
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute(xmlns, localName, "name", "String", parameter.name());
          boolean isFinal = false;
          Type type = parameter.type();
          if (type.asClassDoc() == null) {
              isFinal = true;
          }
          atts.addAttribute(xmlns, localName, "final", "String", ""+ "" + isFinal);
          atts.addAttribute(xmlns, localName, "dimension", "String", parameter.type().dimension());
          cm.startElement(xmlns, localName, "parameter", atts);
  
          // generate "(classref|interfaceref|primitive)" sub-element
          createTypeRef(parameter.type());
  
          cm.endElement(xmlns, localName,"parameter");
      }
  
      /**
       * Generates doc for element "doc"
       * <xmp><!ELEMENT doc (#PCDATA |
       *              linktag |
       *              authortag |
       *              versiontag |
       *              paramtag |
       *              returntag |
       *              exceptiontag |
       *              throwstag |
       *              seetag |
       *              sincetag |
       *              deprecatedtag |
       *              serialtag |
       *              serialfieldtag |
       *              serialdatatag)*></xmp>
       */
      private void docXML(Doc doc) throws SAXException {
          String commentText = "";
          boolean createDoc = false;
          commentText = doc.commentText();
          if (! commentText.equals("")) {
              createDoc = true;
          }
          Tag[] tags = doc.tags();
          if (tags.length > 0) {
              createDoc = true;
          }
          if (createDoc) {
              cm.startElement(xmlns, localName, "doc", emptyAtts);
              if (! commentText.equals("")) {
                  cm.characters(commentText.toCharArray(), 0, commentText.length());
              }
              for (int i = 0; i < tags.length; ++i) {
                  tagXML(tags[i]);
              }
              cm.endElement(xmlns, localName, "doc");
          }
      }
  
      /**
       * Generates doc for all tag elements.
       */
      private void tagXML(Tag tag) throws SAXException {
          String name = tag.name().substring(1) + "tag";
          if (! tag.text().equals("")) {
              cm.startElement(xmlns, localName, name, emptyAtts);
              cm.characters(tag.text().toCharArray(), 0, tag.text().length());
              cm.endElement(xmlns, localName, name);
          }
      }
  
      public static boolean start(RootDoc root) {
          try {
              new XMLDoclet(root);
              return true;
          } catch (Exception e) {
              e.printStackTrace();
              System.exit(1);
              return false;
          }
      }
  }
  
  
  
  1.1                  jakarta-tomcat/src/build/generateModules.xsl
  
  Index: generateModules.xsl
  ===================================================================
  <xsl:stylesheet 
      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0' >
  
  <xsl:output method="xml" indent="yes" />  
  
  <xsl:template match="/">
  <modules>
      <xsl:comment>
  This is automatically generated from the tomcat sources, using Alexandria's 
  XMLDoclet. It is ( will be/can be ) used by configuration tools. One use is 
  in ServerXmlReader to use a simpler syntax.
      </xsl:comment>    
  
      <xsl:for-each select="/javadoc/package/class[ 'org.apache.tomcat.core.BaseInterceptor' = extends_class/classref/@name]">
        <xsl:sort select="/javadoc/package" />
          <module>
            <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
            <xsl:attribute name="javaClass"><xsl:value-of select="../@name"/>.<xsl:value-of select="@name"/></xsl:attribute>
            <category>
                 <xsl:attribute name="name">
                 <xsl:call-template name="lastComponent"> 
                    <xsl:with-param name="full" select="../@name" />
                 </xsl:call-template>
                 </xsl:attribute>
            </category>
            <!-- <xsl:copy-of select="doc" /> -->
            <doc>Not yet</doc>
            <xsl:for-each select="method[substring(@name, 1,3) = 'set']">
               <attribute>
                 <xsl:attribute name="name">
                    <xsl:call-template name="lowerCaseFirst">
                       <xsl:with-param name="n" select="substring( @name, 4)" />
                    </xsl:call-template>
                  </xsl:attribute>
                  <!-- <xsl:copy-of select="doc" />  -->
                  <doc>Not yet</doc>
               </attribute>
            </xsl:for-each>
            <!-- request processing hooks - should be done using special tags -->
            <xsl:if test="method[@name = 'addContext']" ><addContext/></xsl:if>
          </module> 
        <xsl:text>
  
  
  </xsl:text>
        </xsl:for-each>
        
  </modules>
  </xsl:template>
  
  <xsl:template name="lowerCaseFirst">
       <xsl:param name="n"/>
       <xsl:value-of select="concat( translate( substring( $n ,1,1),
  		                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                                     'abcdefghijklmnopqrstuvwxyz'), 
                                     substring($n,2) )"/>
  </xsl:template>
  
  
  <xsl:template name="lastComponent">
      <xsl:param name="full" />
      <xsl:variable name="rest" select="substring-after($full, '.')"/>
      <xsl:if test="not($rest)" ><xsl:value-of select="$full" /></xsl:if>
      <xsl:if test="$rest" >
         <xsl:call-template name="lastComponent"> 
           <xsl:with-param name="full" select="$rest" />
         </xsl:call-template>
      </xsl:if>
  </xsl:template>
    
  </xsl:stylesheet>