cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rica...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xsp XSPProcessor.java
Date Fri, 28 Apr 2000 02:40:27 GMT
ricardo     00/04/27 19:40:27

  Modified:    src/org/apache/cocoon/processor/xsp XSPProcessor.java
  Log:
  Use getAbsolutePath() for determining the source document's filename when getCanonicalPath()
fails. Replaced DOM normalize() by a faster StringBuffer concatenation
  
  Revision  Changes    Path
  1.20      +27 -5     xml-cocoon/src/org/apache/cocoon/processor/xsp/XSPProcessor.java
  
  Index: XSPProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xsp/XSPProcessor.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- XSPProcessor.java	2000/04/08 10:18:18	1.19
  +++ XSPProcessor.java	2000/04/28 02:40:26	1.20
  @@ -1,4 +1,4 @@
  -/*-- $Id: XSPProcessor.java,v 1.19 2000/04/08 10:18:18 stefano Exp $ --
  +/*-- $Id: XSPProcessor.java,v 1.20 2000/04/28 02:40:26 ricardo Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -75,7 +75,7 @@
    * This class implements the XSP engine.
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version $Revision: 1.19 $ $Date: 2000/04/08 10:18:18 $
  + * @version $Revision: 1.20 $ $Date: 2000/04/28 02:40:26 $
    */
   public class XSPProcessor extends AbstractActor
     implements Processor, Configurable, Status
  @@ -279,7 +279,11 @@
       String filename = Utils.getBasename(request, servletContext);
   
       File sourceFile = new File(filename);
  -    filename = sourceFile.getCanonicalPath();
  +    try {
  +      filename = sourceFile.getCanonicalPath();
  +    } catch (IOException e) {
  +      filename = sourceFile.getAbsolutePath();
  +    }
   
       // Get page from Cocoon cache
       PageEntry pageEntry = (PageEntry) this.store.get(filename);
  @@ -373,8 +377,24 @@
   
         // Retrieve and format generated source code
         Element sourceElement = document.getDocumentElement();
  -      sourceElement.normalize();
  -      String sourceCode = sourceElement.getFirstChild().getNodeValue();
  +      // sourceElement.normalize();
  +      // String sourceCode = sourceElement.getFirstChild().getNodeValue();
  +      /*
  +        For large XSP pages normalize() can be
  +	_really_ slow so we do it ourselves
  +      */
  +      StringBuffer buffer = new StringBuffer();
  +      Node node = sourceElement.getFirstChild();
  +      while (node != null) {
  +        switch(node.getNodeType()) {
  +          case Node.TEXT_NODE:
  +          case Node.CDATA_SECTION_NODE:
  +            buffer.append(((Text)node).getData());
  +            break;
  +        }
  +        node = node.getNextSibling();
  +      }
  +      String sourceCode = languageProcessor.formatCode(buffer.toString());      
   
         sourceCode = languageProcessor.formatCode(sourceCode);
   
  @@ -412,7 +432,9 @@
           languageProcessor.unload(page);
         }
   
  +System.err.println("Start compilation: " + new Date());
         languageProcessor.compile(baseName);
  +System.err.println("End compilation: " + new Date());
         this.loadPage(languageProcessor, pageEntry, baseName);
       }
   
  
  
  

Mime
View raw message