jkesselm    00/11/09 10:30:31

  Modified:    java/src/org/apache/xalan/processor
                        CompiledStylesheetBundle.java
                        CompilingStylesheetHandler.java
                        StylesheetHandler.java
  Log:
  Resynchronizing with trax changes
  
  Revision  Changes    Path
  1.9       +15 -13    
xml-xalan/java/src/org/apache/xalan/processor/CompiledStylesheetBundle.java
  
  Index: CompiledStylesheetBundle.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/CompiledStylesheetBundle.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CompiledStylesheetBundle.java     2000/11/03 23:28:02     1.8
  +++ CompiledStylesheetBundle.java     2000/11/09 18:30:29     1.9
  @@ -206,18 +206,20 @@
                                // Asking the classloader to 
getResourceAsStream is our
                                // "best bet" for any caching that may have 
occurred, and 
                                // is the standard solution recommended by Sun.
  -                             //
  -                             // PROBLEM: Microsoft misimplemented that. 
Fetching the
  -                             // resource as c.getClassName returns a null 
pointer;
  -                             // fetching it as a file name throws 
IllegalAgumentException
  -                             // ("Cannot load class files via 
getSystemResource APIs.")
  -                             // So for VJ++ compatability, I'm forced to us 
a workaround.
  -                             
  -                             // Where to copy the classfile from. 
  -                             String source=
  -                                     
packageNameToDirectory(packagename,outdir,File.separatorChar)
  -                                     +shortname+".class";
  -                             java.io.FileInputStream fis=new 
java.io.FileInputStream(source);
  +                             // PROBLEM: Java 1.1 security forbids this and 
throws an
  +                             // exception. For compatability, I'm forced to 
use a fallback;
  +                             // luckily, we _do_ know where we did our 
compilation.
  +                             java.io.InputStream fis;
  +                             if(false) // Works only >= Java 1.2
  +                                     
fis=c.getClass().getResourceAsStream(sink);     
  +                             else
  +                             {                               
  +                                     // Where to copy the classfile from. 
  +                                     String source=
  +                                             
packageNameToDirectory(packagename,outdir,File.separatorChar)
  +                                             +shortname+".class";
  +                                     fis=new java.io.FileInputStream(source);
  +                             }
   
                                // Need to count how many bytes are 
transferred; the ZipEntry
                                // does _NOT_ set itself automatically.
  @@ -418,7 +420,7 @@
                        return c;
                }
                
  -             /** Internal subroutine: Givne the name of a class (or of a 
resource),
  +             /** Internal subroutine: Given the name of a class (or of a 
resource),
                 * access the zipfile and retrieve the contents thereof as a 
byte array.
                 * TODO: Implement the "leading / means already in filename 
syntax" trick?
                 * Or is that irrelevant?
  
  
  
  1.15      +17 -24    
xml-xalan/java/src/org/apache/xalan/processor/CompilingStylesheetHandler.java
  
  Index: CompilingStylesheetHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/CompilingStylesheetHandler.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- CompilingStylesheetHandler.java   2000/11/03 23:28:02     1.14
  +++ CompilingStylesheetHandler.java   2000/11/09 18:30:30     1.15
  @@ -92,8 +92,7 @@
   import org.xml.sax.SAXException;
   import org.xml.sax.SAXParseException;
   
  -// Java Compiler support. *****
  -// TODO: Merge the Microsoft VJ++ workarounds in this file into that one.
  +// Java Compiler support.
   import org.apache.xalan.utils.synthetic.JavaUtils;
   
   /**
  @@ -121,12 +120,6 @@
       super(processor);
     }
     
  -  // TODO: Should we override startElement to redirect ProcessorStylesheet?
  -  // That would let us create a version that had a specialized serializer
  -  // ... if that'd be the best way to handle the "bundling" of the
  -  // generated classes into a .jar/.zip.
  -
  -  
     /**
      * Receive notification of the end of the document.
      * Run standard cleanup of the internal representation,
  @@ -144,11 +137,11 @@
        Vector compiledTemplates=new Vector();
         
       Stylesheet current=getStylesheet();
  -    if(current==getStylesheetRoot())
  +    if(isStylesheetParsingComplete())
       {    
                // Begin compiling. Loop modeled on StylesheetRoot.recompose()
           // calling recomposeTemplates().
  -        StylesheetRoot root=(StylesheetRoot)current;
  +        StylesheetRoot root=(StylesheetRoot)getStylesheetRoot();
           
           // loop from recompose()
           int nImports = root.getGlobalImportCount();
  @@ -193,11 +186,7 @@
           root.recomposeTemplates(true); 
                
                // TODO: Should bundling occur elsewhere?
  -boolean runSerializer=true; // TODO: DEBUG HOOK, CLEAN UP EVENTUALLY
  -if(runSerializer)
  -{    
                CompiledStylesheetBundle.createBundle(root,compiledTemplates);
  -}
       }
     }
     
  @@ -402,7 +391,7 @@
           
compileElemLiteralResult((ElemLiteralResult)kid,body,interpretVector);
                break;
   
  -             // TODO: ***** Redirection of attr value not working yet.       
  +             // TODO: ***** Redirection of attr value not working yet.
        //case Constants.ELEMNAME_ATTRIBUTE:
       //    compileElemAttribute((ElemAttribute)kid,body,interpretVector);
        //    break;
  @@ -829,7 +818,7 @@
           +"// so all the variables can be popped at once when we're done.\n"
           +"org.apache.xpath.VariableStack "+varstackName+" = 
transformer.getXPathContext().getVarStack();\n"
           +varstackName+".pushElemFrame();\n"
  -        +"SourceLocator "+savedLocatorName+" = xctxt.getSAXLocator();\n"
  +        +"javax.xml.transform.SourceLocator "+savedLocatorName+" = 
xctxt.getSAXLocator();\n"
           );
   
         body.append("try {\n\n");
  @@ -916,16 +905,20 @@
       }
   
        // Try to pick up the same classpath we're executing under. That
  -     // ought to include everything in Xalan and the parser...
  +     // ought to include everything in Xalan and the standard libraries.
       String classpath=System.getProperty ("java.class.path");
        
  -     // TODO: These should probably be exposed as params or properties.
  -    boolean debug=true;
  -    boolean generateDebug=true;
  +     // If compiling with the -g switch (Java debugging), we should retain 
  +     // the Java source code to support debugging into the synthesized class.
  +     // Some additional diagnostics are also turned on as a side effect.
  +     // TODO: Find a better place to put the debugging control.
  +     String javac_options=
  +                     
System.getProperty("org.apache.xalan.processor.CompilingStylesheetHandler.options","");
  +     boolean debug=(javac_options.indexOf("-g")>=0);
   
        // Run the compilation. Encapsulates the fallbacks and
        // workarounds needed to achieve this in various environments.
  -     JavaUtils.setDebug(generateDebug);
  +     JavaUtils.setDebug(debug);
       boolean compileOK=
                JavaUtils.JDKcompile(filename,classpath);
        
  @@ -943,13 +936,13 @@
           }
           catch(ClassNotFoundException e)
           {
  -            System.err.println("ERR: Class load failed for "+
  +            System.err.println("ERR: synthesized Template class load failed 
for "+
                   tClass.getName());
               e.printStackTrace();
           }
           catch(org.apache.xalan.utils.synthetic.SynthesisException e)
           {
  -            System.err.println("ERR: Synthetic class realization failed for 
"+
  +            System.err.println("ERR: synthesized Template class realization 
failed for "+
                   tClass.getName());
               e.printStackTrace();
           }
  @@ -957,7 +950,7 @@
       else
       {
           if(debug)
  -            System.err.println("\tCompilation failed; retaining .java file");
  +            System.err.println("\tTemplate compilation failed; retaining 
.java file");
           // This should probably be an exception instead
           System.err.println("ERR: Java compilation failed for "+
                   filename);
  
  
  
  1.19      +24 -0     
xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java
  
  Index: StylesheetHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- StylesheetHandler.java    2000/11/09 00:00:27     1.18
  +++ StylesheetHandler.java    2000/11/09 18:30:30     1.19
  @@ -461,6 +461,23 @@
       m_stylesheetLevel++;
     }
   
  +  // support for isParsingComplete
  +  private boolean m_parsingComplete=false; 
  +
  +  
  +  /** Test whether the _last_ endDocument() has been processed.
  +   * This is needed as guidance for stylesheet optimization
  +   * and compilation engines, which generally don't want to start
  +   * until all included and imported stylesheets have been fully
  +   * parsed.
  +   * 
  +   * @return true iff the complete stylesheet tree has been built.
  +   */
  +  public boolean isStylesheetParsingComplete()
  +  {
  +       return m_parsingComplete;
  +  }
  +
     /**
      * Receive notification of the end of the document.
      *
  @@ -491,6 +508,13 @@
         elemProcessor.startNonText(this);
   
       m_stylesheetLevel--;
  +     
  +     // WARNING: This test works only as long as stylesheets are parsed
  +     // more or less recursively. If we switch to an iterative "work-list"
  +     // model, this will become true prematurely. In that case, 
  +     // isStylesheetParsingComplete() will have to be adjusted to be aware
  +     // of the worklist.
  +     m_parsingComplete=(m_stylesheetLevel<0);
     }
   
     /**
  
  
  

Reply via email to