cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/tools/lib qdox-1.3.jar
Date Fri, 30 Apr 2004 07:20:38 GMT
cziegeler    2004/04/30 00:20:37

  Modified:    tools/src/anttasks ManifestToolTask.java XConfToolTask.java
               src/java/org/apache/cocoon/generation FileGenerator.java
               tools/targets docs-build.xml init-build.xml webapp-build.xml
  Added:       tools/src/anttasks SitemapTask.java DocumentCache.java
               tools/lib qdox-1.3.jar
  Log:
  First silly version of sitemap component doc generation
  - uses file generator as sample
  - unfortunately it has to run twice
  - duplicate qdox jar
  Updated Ant tasks: don't use deprecated methods
  
  Revision  Changes    Path
  1.4       +5 -5      cocoon-2.1/tools/src/anttasks/ManifestToolTask.java
  
  Index: ManifestToolTask.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/tools/src/anttasks/ManifestToolTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ManifestToolTask.java	10 Mar 2004 09:11:50 -0000	1.3
  +++ ManifestToolTask.java	30 Apr 2004 07:20:33 -0000	1.4
  @@ -44,15 +44,15 @@
   
       public void execute() throws BuildException {
           if (this.manifest == null) {
  -            throw new BuildException("manifest attribute is required", location);
  +            throw new BuildException("manifest attribute is required", this.getLocation());
           }
           if (this.directory == null) {
  -            throw new BuildException("directory attribute is required", location);
  +            throw new BuildException("directory attribute is required", this.getLocation());
           }
   
           try {
               // process recursive
  -            this.process(this.project.resolveFile(this.directory), this.manifest);
  +            this.process(this.getProject().resolveFile(this.directory), this.manifest);
           } catch (IOException ioe) {
               throw new BuildException("IOException: " + ioe);
           }
  @@ -66,7 +66,7 @@
       throws IOException, BuildException {
   
           System.out.println("Writing: " + manifest);
  -        FileWriter w = new FileWriter(this.project.resolveFile(manifest));
  +        FileWriter w = new FileWriter(this.getProject().resolveFile(manifest));
           w.write("Manifest-Version: 1.0\n");
   
           if (directoryFile.exists() && directoryFile.isDirectory() ) {
  
  
  
  1.24      +20 -69    cocoon-2.1/tools/src/anttasks/XConfToolTask.java
  
  Index: XConfToolTask.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/tools/src/anttasks/XConfToolTask.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XConfToolTask.java	18 Mar 2004 10:56:53 -0000	1.23
  +++ XConfToolTask.java	30 Apr 2004 07:20:34 -0000	1.24
  @@ -14,38 +14,28 @@
    * limitations under the License.
    */
   
  +import java.io.File;
  +import java.io.IOException;
  +import java.net.UnknownHostException;
  +import java.util.ArrayList;
  +import java.util.Iterator;
  +
  +import javax.xml.transform.TransformerException;
  +
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.taskdefs.MatchingTask;
   import org.apache.tools.ant.types.XMLCatalog;
   import org.apache.xpath.XPathAPI;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentType;
   import org.w3c.dom.DOMException;
  +import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.NodeList;
   import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
   import org.xml.sax.SAXException;
   
  -import javax.xml.parsers.DocumentBuilderFactory;
  -import javax.xml.parsers.DocumentBuilder;
  -import javax.xml.parsers.ParserConfigurationException;
  -import javax.xml.transform.OutputKeys;
  -import javax.xml.transform.TransformerFactory;
  -import javax.xml.transform.Transformer;
  -import javax.xml.transform.TransformerException;
  -import javax.xml.transform.dom.DOMSource;
  -import javax.xml.transform.stream.StreamResult;
  -import java.io.File;
  -import java.io.IOException;
  -import java.net.UnknownHostException;
  -import java.util.ArrayList;
  -import java.util.HashMap;
  -import java.util.Iterator;
  -import java.util.Map;
  -
   /**
    * Ant task to patch xmlfiles.
    *
  @@ -73,17 +63,12 @@
       private static final String NL=System.getProperty("line.separator");
       private static final String FSEP=System.getProperty("file.separator");
       
  -    /** Cache the read configuration files (Documents) */
  -    private static Map fileCache = new HashMap();
  -    
       private File file;
       //private File directory;
       private File srcdir;
       private boolean addComments;
       /** for resolving entities such as dtds */
       private XMLCatalog xmlCatalog = new XMLCatalog();
  -    private DocumentBuilder builder;
  -    private Transformer transformer;
   
       /**
        * Set file, which should be patched.
  @@ -125,22 +110,7 @@
        */
       public void init() throws BuildException {
           super.init();
  -        try {
  -            xmlCatalog.setProject(project);
  -            DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
  -            builderFactory.setValidating(false);
  -            builderFactory.setExpandEntityReferences(false);
  -            builderFactory.setNamespaceAware(false);
  -            builderFactory.setAttribute(
  -               "http://apache.org/xml/features/nonvalidating/load-external-dtd",
  -               Boolean.FALSE);
  -            builder = builderFactory.newDocumentBuilder();
  -            transformer = TransformerFactory.newInstance().newTransformer();
  -        } catch (TransformerException e) {
  -            throw new BuildException("TransformerException: "+e);
  -        } catch (ParserConfigurationException e) {
  -            throw new BuildException("ParserConfigurationException: "+e);
  -        }  
  +        xmlCatalog.setProject(this.getProject());
       }
   
       /**
  @@ -148,23 +118,14 @@
        */
       public void execute() throws BuildException {
           if (this.file == null) {
  -            throw new BuildException("file attribute is required", location);
  +            throw new BuildException("file attribute is required", this.getLocation());
           }
           try {
               final String fileName = this.file.toURL().toExternalForm();
  -            Document document = (Document)this.fileCache.get(fileName);
  -            if ( document != null ) {
  -                log("Using file from cache: " + this.file, Project.MSG_DEBUG);
  -                this.fileCache.remove(fileName);
  -            } else {
  -
  -                // load xml
  -                log("Reading: " + this.file, Project.MSG_DEBUG);
  -                document = builder.parse(fileName);
  -            }
  +            Document document = DocumentCache.getDocument(fileName, this);
               
               if (this.srcdir == null) {
  -                this.srcdir = project.resolveFile(".");
  +                this.srcdir = this.getProject().resolveFile(".");
               }
   
               DirectoryScanner scanner = getDirectoryScanner(this.srcdir);
  @@ -221,24 +182,15 @@
               }
   
               if (modified) {
  -                log("Writing: " + this.file);
  -                // Set the DOCTYPE output option on the transformer 
  -                // if we have any DOCTYPE declaration in the input xml document
  -                final DocumentType doctype = document.getDoctype();
  -                if (null != doctype && null != doctype.getPublicId()) {
  -                    transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctype.getPublicId());
  -                    transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctype.getSystemId());
  -                }
  -                transformer.transform(new DOMSource(document),
  -                                      new StreamResult(this.file));
  +                DocumentCache.writeDocument(this.file, document, this);
               } else {
                   log("No Changes: " + this.file, Project.MSG_DEBUG);
               }
  -            this.fileCache.put(fileName, document);
  +            DocumentCache.storeDocument(fileName, document, this);
           } catch (TransformerException e) {
               throw new BuildException("TransformerException: "+e);
           } catch (SAXException e) {
  -            throw new BuildException("SAXException: "+e);
  +            throw new BuildException("SAXException:" +e);           
           } catch (DOMException e) {
               throw new BuildException("DOMException:" +e);           
           } catch (UnknownHostException e) {
  @@ -264,7 +216,7 @@
                             final File file)
                             throws TransformerException, IOException, DOMException, SAXException
{
   
  -        Document component = builder.parse(file.toURL().toExternalForm());
  +        Document component = DocumentCache.getDocument(file.toURL().toExternalForm(), this);
           String filename = file.toString();
                               
           // Check to see if Document is an xconf-tool document
  @@ -305,7 +257,7 @@
           String ifProp = getAttribute(elem, "if-prop", replaceProperties);
           boolean ifValue = false;
           if (ifProp != null && !ifProp.equals("")) {
  -            ifValue = Boolean.valueOf(project.getProperty(ifProp)).booleanValue();
  +            ifValue = Boolean.valueOf(this.getProject().getProperty(ifProp)).booleanValue();
           }
   
           if (ifProp != null && ifProp.length() > 0 && !ifValue ) {
  @@ -318,7 +270,6 @@
           } else {
               // Test if component wants us to remove a list of nodes first
               xpath = getAttribute(elem, "remove", replaceProperties);
  -            Node remove = null;
   
               if (xpath != null && xpath.length() > 0) {
                   nodes = XPathAPI.selectNodeList(configuration, xpath);
  
  
  
  1.1                  cocoon-2.1/tools/src/anttasks/SitemapTask.java
  
  Index: SitemapTask.java
  ===================================================================
  /* 
   * Copyright 2003-2004 The Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.xpath.XPathAPI;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  import com.thoughtworks.qdox.ant.AbstractQdoxTask;
  import com.thoughtworks.qdox.model.DocletTag;
  import com.thoughtworks.qdox.model.JavaClass;
  
  /**
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Revision: 1.1 $ $Date: 2004/04/30 07:20:34 $
   */
  public final class SitemapTask extends AbstractQdoxTask {
  
      /** The name of the component in the sitemap (required) */    
      public static final String NAME_TAG   = "cocoon.sitemap.component.name";
      /** The logger category (optional) */
      public static final String LOGGER_TAG = "cocoon.sitemap.component.logger";
      /** The label for views (optional) */
      public static final String LABEL_TAG  = "cocoon.sitemap.component.label";
      /** If this tag is specified, the component is not added to the sitemap (optional) */
      public static final String HIDDEN_TAG = "cocoon.sitemap.component.hide";
      /** If this tag is specified no documentation is generated (optional) */
      public static final String NO_DOC_TAG = "cocoon.sitemap.component.documentation.disabled";
      /** The documentation (optional) */
      public static final String DOC_TAG    = "cocoon.sitemap.component.documentation";
      
      /** Pooling min (optional) */
      public static final String POOL_MIN_TAG = "cocoon.sitemap.component.pooling.min";
      /** Pooling max (optional) */
      public static final String POOL_MAX_TAG = "cocoon.sitemap.component.pooling.max";
      /** Pooling grow (optional) */
      public static final String POOL_GROW_TAG = "cocoon.sitemap.component.pooling.grow";
      
      private static final String LINE_SEPARATOR = "\n";//System.getProperty("line.separator");
      
      /** The sitemap namespace. TODO - this has to be configurable for newer versions! */
      private static final String SITEMAP_NS = "http://apache.org/cocoon/sitemap/1.0";
      
      /** The sitemap */
      private File sitemap;
      
      /** The doc dir */
      private File docDir;
      
      /** The components */
      private List components = new ArrayList();
      
      public void setSitemap( final File sitemap ) {
          this.sitemap = sitemap;
      }
  
      public void setDocDir( final File dir ) {
          this.docDir = dir;        
      }
      
      /**
       * Execute generator task.
       *
       * @throws BuildException if there was a problem collecting the info
       */
      public void execute()
      throws BuildException {
  
          validate();
  
          // this does the hard work :)
          super.execute();
  
          try {
              
              this.collectInfo();
              if ( this.sitemap != null ) {
                  this.processSitemap();
              }
              if ( this.docDir != null ) {
                  this.processDocDir();
              }
              
          } catch ( final BuildException e ) {
              throw e;
          } catch ( final Exception e ) {
              throw new BuildException( e.toString(), e );
          }
      }
  
      /**
       * Validate that the parameters are valid.
       */
      private void validate() {
          if ( this.sitemap == null && this.docDir == null ) {
              throw new BuildException("Sitemap or DocDir is not specified.");
          }
          
          if ( this.sitemap != null && this.sitemap.isDirectory() ) {
              throw new BuildException( "Sitemap (" + this.sitemap + ") is not a file." );
          }
          if ( this.docDir != null && !this.docDir.isDirectory() ) {
              throw new BuildException( "DocDir (" + this.docDir + ") is not a directory."
);            
          }
      }
  
      /**
       * Collect the component infos
       */
      private void collectInfo() {
          log("Collection sitemap components info");
          final Iterator it = super.allClasses.iterator();
          
          while ( it.hasNext() ) {
              final JavaClass javaClass = (JavaClass) it.next();
  
              final DocletTag tag = javaClass.getTagByName( NAME_TAG );
  
              if ( null != tag ) {
                  final SitemapComponent comp = new SitemapComponent( javaClass );
  
                  log("Found component: " + comp, Project.MSG_DEBUG);
                  this.components.add(comp);
              }
          }
      }
  
      /**
       * Add components to sitemap
      */
      private void processSitemap() 
      throws Exception {
          log("Adding sitemap components");
          final String fileName = this.sitemap.toURL().toExternalForm();
          Document document;
          
          document = DocumentCache.getDocument(fileName, this);
          
          boolean changed = false;
  
          Iterator iter = this.components.iterator();
          while ( iter.hasNext() ) {
              SitemapComponent component = (SitemapComponent)iter.next();
              final String type = component.getType();
              final String section = type + 's';
              
              NodeList nodes = XPathAPI.selectNodeList(document, "/sitemap/components/" +
section);
  
              if (nodes.getLength() != 1 ) {
                  throw new BuildException("Unable to find section for component type " +
type);
              }
              // remove old node!
              NodeList oldNodes = XPathAPI.selectNodeList(document, 
                      "/sitemap/components/" + section + '/' + type + "[@name='" + component.getName()
+ "']");
              for(int i=0; i < oldNodes.getLength(); i++ ) {
                  final Node node = oldNodes.item(i);
                  node.getParentNode().removeChild(node);
              }
              
              // and add it again
              if (component.append(nodes.item(0)) ) {
                  changed = true;
              }
              
          }
          
          if ( changed ) {
              DocumentCache.writeDocument(this.sitemap, document, this);
          }
          DocumentCache.storeDocument(fileName, document, this);
      }
      
      /**
       * Add components to sitemap
      */
      private void processDocDir() 
      throws Exception {
          log("Generating documentation");
  
          Iterator iter = this.components.iterator();
          while ( iter.hasNext() ) {
              final SitemapComponent component = (SitemapComponent)iter.next();
              
              component.generateDocs(this.docDir);
          }
          
      }
  
      static final class SitemapComponent {
          
          final protected JavaClass javaClass;
          final String    name;
          final String    type;
          
          public SitemapComponent(JavaClass javaClass) {
              this.javaClass = javaClass;
              
              this.name = javaClass.getTagByName( NAME_TAG ).getValue();            
              this.type = getType(this.javaClass);
          }
          
          /* (non-Javadoc)
           * @see java.lang.Object#toString()
           */
          public String toString() {
              return "Sitemap component: " + this.javaClass.getName();
          }
          
          public String getType() {
              return this.type;
          }
          
          public String getName() {
              return this.name;
          }
          
          public boolean append(Node parent) {
              if ( this.getTagValue(HIDDEN_TAG, null) != null ) {
                  return false;
              }
              Document doc = parent.getOwnerDocument();
              Node node;
              StringBuffer buffer = new StringBuffer();
              
              // first check: deprecated?
              if ( this.getTagValue("deprecated", null) != null ) {
                  indent(parent, 3);
                  buffer.append("The ")
                  .append(this.type)
                  .append(" ")
                  .append(this.name)
                  .append(" is deprecated");
                  node = doc.createComment(buffer.toString());
                  parent.appendChild(node);
                  newLine(parent);
                  buffer = new StringBuffer();
              }
              indent(parent, 3);
              node = doc.createElementNS(SITEMAP_NS, "map:" + this.type);
              ((Element)node).setAttribute("name", this.name);
              ((Element)node).setAttribute("src", this.javaClass.getFullyQualifiedName());
              
              // test for logger
              // TODO Default logger?
              if ( this.javaClass.isA("org.apache.avalon.framework.logger.LogEnabled") ) {
                  this.addAttribute(node, LOGGER_TAG, "logger", null);
              }
              
              // test for label
              this.addAttribute(node, LABEL_TAG, "label", null);
  
              if ( this.javaClass.isA("org.apache.avalon.excalibur.pool.Poolable") ) {
                  // TODO - Think about default values
                  this.addAttribute(node, POOL_MIN_TAG, "pool-min", null);
                  this.addAttribute(node, POOL_MAX_TAG, "pool-max", null);
                  this.addAttribute(node, POOL_GROW_TAG, "pool-grow", null);
              }
              parent.appendChild(node);
              newLine(parent);
              // TODO Add configuration
  
              return true;
          }
          
          private void addAttribute(Node node, String tag, String attributeName, String defaultValue)
{
              final String tagValue = this.getTagValue(tag, defaultValue);
              if ( tagValue != null ) {
                  ((Element)node).setAttribute(attributeName, tagValue);
              }
          }
          
          private static void newLine(Node node) {
              final Node n = node.getOwnerDocument().createTextNode(LINE_SEPARATOR);
              node.appendChild(n);
          }
          
          private static void indent(Node node, int depth) {
              final StringBuffer buffer = new StringBuffer();
              for(int i=0; i < depth*2; i++ ) {
                  buffer.append(' ');
              }
              final Node n = node.getOwnerDocument().createTextNode(buffer.toString());
              node.appendChild(n);
          }
          
          public void generateDocs(File parentDir) {
              final String doc = this.getDocumentation();
              if ( doc == null ) {
                  return;
              }
              try {
                  final File componentsDir = new File(parentDir, this.type+'s');
                  componentsDir.mkdir();
                  
                  final File docFile = new File(componentsDir, this.name + ".txt");
                  docFile.createNewFile();
                  
                  final FileWriter writer = new FileWriter(docFile);
                  writer.write(doc);
                  writer.close();
              } catch (IOException ioe) {
                  throw new BuildException("Error writing doc.", ioe);
              }
          }
          
          /**
           * Return the documentation or null
           * @return
           */
          private String getDocumentation() {
              if ( this.getTagValue(NO_DOC_TAG, null) != null ) {
                  return null;
              }
              return this.getTagValue(DOC_TAG, null);
          }
          
          private String getTagValue(String tagName, String defaultValue) {
              final DocletTag tag = javaClass.getTagByName( tagName );
              if ( tag != null ) {
                  return tag.getValue();
              }
              return defaultValue;
          }
          
          private static String getType(JavaClass clazz) {
              if ( clazz.isA("org.apache.cocoon.generation.Generator") ) {
                  return "generator";
              } else if ( clazz.isA("org.apache.cocoon.transformation.Transformer") ) {
                  return "transformer";
              } else if ( clazz.isA("org.apache.cocoon.reading.Reader") ) {
                  return "reader";
              } else if ( clazz.isA("org.apache.cocoon.serialization.Serializer") ) {
                  return "serializer";
              } else if ( clazz.isA("org.apache.cocoon.acting.Action") ) {
                  return "action";
              } else if ( clazz.isA("org.apache.cocoon.matching.Matcher") ) {
                  return "matcher";
              } else if ( clazz.isA("org.apache.cocoon.selection.Selector") ) {
                  return "selector";
              } else if ( clazz.isA("org.apache.cocoon.components.pipeline.ProcessingPipeline")
) {
                  return "pipe";
              } else {
                  throw new BuildException("Sitemap component " + clazz.getName() + " does
not implement a sitemap component interface.");
              }            
          }
      }
  }
  
  
  
  1.1                  cocoon-2.1/tools/src/anttasks/DocumentCache.java
  
  Index: DocumentCache.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.io.File;
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.xml.parsers.DocumentBuilder;
  import javax.xml.parsers.DocumentBuilderFactory;
  import javax.xml.parsers.ParserConfigurationException;
  import javax.xml.transform.OutputKeys;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerException;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.dom.DOMSource;
  import javax.xml.transform.stream.StreamResult;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Task;
  import org.w3c.dom.Document;
  import org.w3c.dom.DocumentType;
  import org.xml.sax.SAXException;
  
  /**
   * 
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Revision: 1.1 $ $Date: 2004/04/30 07:20:34 $
   */
  public final class DocumentCache {
  
      /** Cache the read configuration files (Documents) */
      protected static Map fileCache = new HashMap();
      
      /** The document builder */
      private static DocumentBuilder builder;
      private static Transformer transformer;
  
      /**
       * Initialize internal instance of XMLCatalog
       */
      static {
          try {
              DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
              builderFactory.setValidating(false);
              builderFactory.setExpandEntityReferences(false);
              builderFactory.setNamespaceAware(false);
              builderFactory.setAttribute(
                 "http://apache.org/xml/features/nonvalidating/load-external-dtd",
                 Boolean.FALSE);
              builder = builderFactory.newDocumentBuilder();
              transformer = TransformerFactory.newInstance().newTransformer();
          } catch (TransformerException e) {
              throw new BuildException("TransformerException: "+e);
          } catch (ParserConfigurationException e) {
              throw new BuildException("ParserConfigurationException: "+e);
          }  
      }
  
      public static Document getDocument(String fileName, Task task) 
      throws SAXException {
          Document document = (Document)fileCache.get(fileName);
          if ( document != null ) {
              task.log("Using file from cache: " + fileName, Project.MSG_DEBUG);
              fileCache.remove(fileName);
          } else {
              try {
                  // load xml
                  task.log("Reading: " + fileName, Project.MSG_DEBUG);
                  document = builder.parse(fileName);
              } catch (IOException e) {
                  throw new BuildException("IOException: "+e);
              }                
          }
          return document;
      }
      
      public static void storeDocument(String fileName, Document document, Task task) {  
          task.log("Storing file in cache: " + fileName, Project.MSG_DEBUG);
          fileCache.put(fileName, document);
      }
  
      public static void writeDocument(File file, Document document, Task task) {
          task.log("Writing: " + file);
          // Set the DOCTYPE output option on the transformer 
          // if we have any DOCTYPE declaration in the input xml document
          final DocumentType doctype = document.getDoctype();
          if (null != doctype && null != doctype.getPublicId()) {
              transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctype.getPublicId());
              transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctype.getSystemId());
          }
          
          try {
              transformer.transform(new DOMSource(document),
                                    new StreamResult(file));
          } catch (TransformerException e) {
              throw new BuildException("TransformerException: "+e);
          }
      }
  }
  
  
  
  1.7       +9 -2      cocoon-2.1/src/java/org/apache/cocoon/generation/FileGenerator.java
  
  Index: FileGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/FileGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FileGenerator.java	5 Mar 2004 13:02:55 -0000	1.6
  +++ FileGenerator.java	30 Apr 2004 07:20:36 -0000	1.7
  @@ -29,10 +29,17 @@
   import java.util.Map;
   
   /**
  - *
  + * @cocoon.sitemap.component.documentation
    * The <code>FileGenerator</code> is a class that reads XML from a source
    * and generates SAX Events.
    * The FileGenerator implements the <code>CacheableProcessingComponent</code>
interface.
  + * 
  + * @cocoon.sitemap.component.name   file
  + * @cocoon.sitemap.component.label  content
  + * @cocoon.sitemap.component.logger sitemap.generator.file
  + * @cocoon.sitemap.component.pooling.min   8
  + * @cocoon.sitemap.component.pooling.max  32
  + * @cocoon.sitemap.component.pooling.grow  4
    *
    * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation)
  
  
  
  1.9       +7 -0      cocoon-2.1/tools/targets/docs-build.xml
  
  Index: docs-build.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/tools/targets/docs-build.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- docs-build.xml	2 Apr 2004 19:07:49 -0000	1.8
  +++ docs-build.xml	30 Apr 2004 07:20:36 -0000	1.9
  @@ -49,6 +49,13 @@
       <copy file="status.xml"
         tofile="${build.context}/xdocs/status.xml" filtering="on"/>
   
  +	<!-- generate sitemap components docs -->
  +    <sitemap-components docDir="${build.context}/xdocs/userdocs">
  +      <fileset dir="${java}">
  +        <include name="**/*.java"/>
  +      </fileset>
  +    </sitemap-components>
  +
       <!-- Forrest needs its own file at src/documentation/sitemap.xmap, so we
       overwrite it with the old Cocoon-specific sitemap here -->
       <move file="${build.context}/sitemap-localdocs.xmap"
  
  
  
  1.14      +5 -0      cocoon-2.1/tools/targets/init-build.xml
  
  Index: init-build.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/tools/targets/init-build.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- init-build.xml	2 Apr 2004 19:07:49 -0000	1.13
  +++ init-build.xml	30 Apr 2004 07:20:36 -0000	1.14
  @@ -162,6 +162,11 @@
       <taskdef name="xpatch" classname="XConfToolTask"
              classpath="${tools.tasks.dest}"/>
   
  +    <!-- A task for sitemap components -->
  +    <taskdef name="sitemap-components" 
  +            classname="SitemapTask"
  +            classpathref="tasks.classpath"/>
  +
       <!-- Jing is used in various targets for XML validation with RELAX NG -->
       <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"
              classpathref="tasks.classpath"/>
  
  
  
  1.16      +7 -0      cocoon-2.1/tools/targets/webapp-build.xml
  
  Index: webapp-build.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/tools/targets/webapp-build.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- webapp-build.xml	28 Apr 2004 21:29:08 -0000	1.15
  +++ webapp-build.xml	30 Apr 2004 07:20:36 -0000	1.16
  @@ -28,6 +28,13 @@
       <copy file="${webapp}/welcome.xslt" tofile="${build.webapp}/welcome.xslt" filtering="on"/>
       <copy file="${webapp}/sitemap.xmap" tofile="${build.webapp}/sitemap.xmap"/>
   
  +	<!-- generate sitemap entries -->
  +    <sitemap-components sitemap="${build.webapp}/sitemap.xmap">
  +      <fileset dir="${java}">
  +        <include name="**/*.java"/>
  +      </fileset>
  +    </sitemap-components>
  +
       <copy todir="${build.webapp}/stylesheets" filtering="on">
         <fileset dir="${webapp}/stylesheets">
           <include name="**/*.xslt"/>
  
  
  
  1.1                  cocoon-2.1/tools/lib/qdox-1.3.jar
  
  	<<Binary file>>
  
  

Mime
View raw message