grchiu      2003/09/11 08:55:45

  Modified:    java/samples/Trace Trace.java
  Log:
  Update Trace sample to allow tracing of extension calls, as well as
  optionally read the name of the stylesheet from the command line arguments.
  
  Revision  Changes    Path
  1.8       +17 -5     xml-xalan/java/samples/Trace/Trace.java
  
  Index: Trace.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/samples/Trace/Trace.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Trace.java        30 Jan 2003 18:21:50 -0000      1.7
  +++ Trace.java        11 Sep 2003 15:55:45 -0000      1.8
  @@ -65,6 +65,12 @@
   import org.apache.xalan.trace.TraceManager;
   import org.apache.xalan.transformer.TransformerImpl;
   
  +/**
  + * Sample for demonstrating Xalan "trace" interface.
  + * Usage: run in Trace directory: java Trace
  + * For an extensions trace sample, run in extensions
  + * directory: java Trace 3-java-namespace
  + */
   public class Trace
   {    
     public static void main (String[] args)
  @@ -73,6 +79,10 @@
                         java.util.TooManyListenersException, 
                         org.xml.sax.SAXException                        
     {
  +    String fileName = "foo";
  +    if (args.length > 0)
  +      fileName = args[0];
  +
       // Set up a PrintTraceListener object to print to a file.
       java.io.FileWriter fw = new java.io.FileWriter("events.log");  
       java.io.PrintWriter pw = new java.io.PrintWriter(fw, true);
  @@ -86,10 +96,12 @@
       ptl.m_traceSelection = true;
       // Print information whenever a template is invoked.
       ptl.m_traceTemplates = true;
  +    // Print information whenever an extension call is made.
  +    ptl.m_traceExtension = true;
   
       // Set up the transformation    
        TransformerFactory tFactory = TransformerFactory.newInstance();
  -    Transformer transformer = tFactory.newTransformer(new 
StreamSource("foo.xsl"));
  +    Transformer transformer = tFactory.newTransformer(new 
StreamSource(fileName + ".xsl"));
   
       // Cast the Transformer object to TransformerImpl.
       if (transformer instanceof TransformerImpl) 
  @@ -103,13 +115,13 @@
         // Perform the transformation --printing information to
         // the events log during the process.
         transformer.transform
  -                         ( new StreamSource("foo.xml"), 
  -                           new StreamResult(new 
java.io.FileWriter("foo.out")) );
  +                         ( new StreamSource(fileName + ".xml"), 
  +                           new StreamResult(new java.io.FileWriter(fileName 
+ ".out")) );
       }
       // Close the PrintWriter and FileWriter.
       pw.close();
       fw.close();
  -     System.out.println("**The output is in foo.out; the log is in 
events.log ****");        
  +     System.out.println("**The output is in " + fileName + ".out; the log is 
in events.log ****");   
       
     }
  -}
  \ No newline at end of file
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to