sboag       00/10/09 16:25:23

  Modified:    java     Makefile
               java/src makexslt4j
               java/src/org/apache/xalan/processor StylesheetProcessor.java
               java/src/org/apache/xalan/res XSLTInfo.properties
               java/src/org/apache/xalan/stree AttrImpl.java
                        AttrImplNS.java CDATASectionImpl.java Child.java
                        CommentImpl.java DocumentFragmentImpl.java
                        DocumentImpl.java DocumentTypeImpl.java
                        ElementImpl.java ElementImplWithNS.java
                        IndexedElemImpl.java IndexedElemWithNS.java
                        NameSpaceDecl.java Parent.java
                        ProcessingInstructionImpl.java
                        SourceTreeHandler.java TextImpl.java
                        WhiteSpace.java
               java/src/org/apache/xalan/templates FuncDocument.java
               java/src/org/apache/xalan/transformer TransformerImpl.java
               java/src/org/apache/xalan/utils DOMBuilder.java
                        SystemIDResolver.java TreeWalker.java
               java/src/org/apache/xalan/xslt Process.java
               java/src/org/apache/xpath SourceTreeManager.java XPath.java
                        XPathContext.java
               java/src/trax Processor.java ProcessorException.java
                        TransformException.java trax.properties
  Log:
  Changed how "trax.properties" is accessed.  See note on Xalan list.
   Moved transformation to secondary thread, and parser to main thread.
   Use "http://xml.apache.org/xslt/sourcebase"; to set base URL for input source.
  
  Revision  Changes    Path
  1.4       +1 -0      xml-xalan/java/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/Makefile,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Makefile  2000/10/02 23:37:43     1.3
  +++ Makefile  2000/10/09 23:25:14     1.4
  @@ -54,6 +54,7 @@
        $(CP) src/$(PROPPATH)/*.properties src/$(CLASS_DIR)/$(PROPPATH)/.; \
        $(CP) src/serialize/*.properties src/$(CLASS_DIR)/serialize/.; \
        $(CP) src/org/apache/xml/serialize/transition/*.res 
src/$(CLASS_DIR)/org/apache/xml/serialize/transition/.; \
  +     $(CP) src/trax/*.properties src/$(CLASS_DIR)/trax/.; \
        echo -n "Jarring ../bin/$@ .. "; \
        cd src/$(CLASS_DIR); $(JAR) $(JARFLAGS) ../../bin/$@ org trax serialize 
synthetic; \
        echo "done"
  
  
  
  1.16      +54 -0     xml-xalan/java/src/makexslt4j
  
  Index: makexslt4j
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/makexslt4j,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- makexslt4j        2000/10/06 07:58:27     1.15
  +++ makexslt4j        2000/10/09 23:25:14     1.16
  @@ -257,6 +257,60 @@
     synthetic$(PATHSEP)reflection$(PATHSEP)Member.java \
     synthetic$(PATHSEP)reflection$(PATHSEP)Method.java \
     org$(PATHSEP)w3c$(PATHSEP)xslt$(PATHSEP)ExpressionContext.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Attr.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)CDATASection.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)CharacterData.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Comment.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Document.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)DocumentFragment.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)DocumentType.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)DOMException.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)DOMImplementation.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Element.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Entity.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)EntityReference.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)NamedNodeMap.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Node.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)NodeList.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Notation.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)ProcessingInstruction.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)Text.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)range$(PATHSEP)DocumentRange.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)range$(PATHSEP)Range.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)range$(PATHSEP)RangeException.java \
  +  
org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)traversal$(PATHSEP)DocumentTraversal.java
 \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)traversal$(PATHSEP)NodeFilter.java \
  +  
org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)traversal$(PATHSEP)NodeIterator.java \
  +  org$(PATHSEP)w3c$(PATHSEP)dom$(PATHSEP)traversal$(PATHSEP)TreeWalker.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)AttributeList.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)Attributes.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)ContentHandler.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)DocumentHandler.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)DTDHandler.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)EntityResolver.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)ErrorHandler.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)HandlerBase.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)InputSource.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)Locator.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)Parser.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)SAXException.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)SAXNotRecognizedException.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)SAXNotSupportedException.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)SAXParseException.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)XMLFilter.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)XMLReader.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)ext$(PATHSEP)DeclHandler.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)ext$(PATHSEP)LexicalHandler.java \
  +  
org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)AttributeListImpl.java \
  +  
org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)AttributesImpl.java \
  +  
org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)DefaultHandler.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)LocatorImpl.java \
  +  
org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)NamespaceSupport.java \
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)ParserAdapter.java 
\
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)ParserFactory.java 
\
  +  org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)XMLFilterImpl.java 
\
  +  
org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)XMLReaderAdapter.java \
  +  
org$(PATHSEP)xml$(PATHSEP)sax$(PATHSEP)helpers$(PATHSEP)XMLReaderFactory.java \
     
org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)BaseMarkupSerializer.java
 \
     
org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)ElementState.java
 \
     
org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)Encodings.java
 \
  
  
  
  1.6       +64 -0     
xml-xalan/java/src/org/apache/xalan/processor/StylesheetProcessor.java
  
  Index: StylesheetProcessor.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetProcessor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StylesheetProcessor.java  2000/09/07 19:47:59     1.5
  +++ StylesheetProcessor.java  2000/10/09 23:25:15     1.6
  @@ -73,6 +73,12 @@
   import trax.Templates;
   import trax.TemplatesBuilder;
   
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.io.BufferedInputStream;
  +import java.util.Properties;
  +import java.util.Enumeration;
  +
   /**
    * The StylesheetProcessor, which implements the TRaX Processor 
    * interface, processes XSLT stylesheets into a Templates object 
  @@ -80,6 +86,60 @@
    */
   public class StylesheetProcessor extends Processor
   {  
  +  public static String XSLT_PROPERTIES = 
"/org/apache/xalan/res/XSLTInfo.properties";
  +
  +  private static boolean isInited = false;
  +    
  +  public StylesheetProcessor()
  +  {
  +    loadPropertyFileToSystem(XSLT_PROPERTIES);
  +  }
  +  
  +  /*
  +  * Retrieve a propery bundle from a specified file and load it 
  +  * int the System properties.
  +  * @param file The string name of the property file.  
  +  */
  +  private static void loadPropertyFileToSystem(String file) 
  +  {
  +    if(false == isInited)
  +    {
  +      try
  +      {
  +        InputStream is;
  +        try
  +        {               
  +          Properties props = new Properties();
  +          is = Process.class.getResourceAsStream(file);    
  +          // get a buffered version
  +          BufferedInputStream bis = new BufferedInputStream (is);
  +          props.load (bis);                                     // and load 
up the property bag from this
  +          bis.close ();                                          // close 
out after reading
  +          // OK, now we only want to set system properties that 
  +          // are not already set.
  +          Properties systemProps = System.getProperties();
  +          Enumeration propEnum = props.propertyNames();
  +          while(propEnum.hasMoreElements())
  +          {
  +            String prop = (String)propEnum.nextElement();
  +            if(!systemProps.containsKey(prop))
  +              systemProps.put(prop, props.getProperty(prop));
  +          }
  +          System.setProperties(systemProps);
  +          isInited = true;
  +        }
  +        catch (Exception ex)
  +        {
  +        }
  +      }
  +      catch(SecurityException se)
  +      {
  +        // In this case the caller is required to have 
  +        // the needed attributes already defined.
  +      }
  +    }
  +  }
  +
     /**
      * Process the source into a templates object.
      * 
  @@ -96,6 +156,10 @@
       {
         reader = XMLReaderFactory.createXMLReader();
       }
  +    // If you set the namespaces to true, we'll end up getting double 
  +    // xmlns attributes.  Needs to be fixed.  -sb
  +    // reader.setFeature("http://xml.org/sax/features/namespace-prefixes";, 
true);
  +    reader.setFeature("http://apache.org/xml/features/validation/dynamic";, 
true);
       reader.setContentHandler(builder);
       reader.parse(source);
       return builder.getTemplates();
  
  
  
  1.4       +3 -6      
xml-xalan/java/src/org/apache/xalan/res/XSLTInfo.properties
  
  Index: XSLTInfo.properties
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/res/XSLTInfo.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSLTInfo.properties       2000/09/21 19:15:43     1.3
  +++ XSLTInfo.properties       2000/10/09 23:25:15     1.4
  @@ -6,11 +6,8 @@
   vendor=Apache Software Foundation
   vendor-url=http://xml.apache.org/xalan
   
  -# The TRaX Stylesheet processor
  -trax.processor.xslt=org.apache.xalan.processor.StylesheetProcessor
  -
   # The XML Parser for SAX2
  +# Since XMLReaderFactory doesn't have it's own properties file, 
  +# but simply reads the system properties, Xalan tries to load 
  +# this value into the system properties.
   org.xml.sax.driver=org.apache.xerces.parsers.SAXParser
  -
  -# Use this property for backwards compatibility with Xerces Liaison.
  -# org.apache.xalan.source.liaison=org.apache.xalan.xpath.dtm.DTMLiaison
  
  
  
  1.3       +2 -1      xml-xalan/java/src/org/apache/xalan/stree/AttrImpl.java
  
  Index: AttrImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/AttrImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AttrImpl.java     2000/07/05 14:39:00     1.2
  +++ AttrImpl.java     2000/10/09 23:25:15     1.3
  @@ -12,8 +12,9 @@
     private String m_value;
     private boolean m_specified = true;
     
  -  AttrImpl(String name, String value)
  +  AttrImpl(DocumentImpl doc, String name, String value)
     {
  +    super(doc);
       m_name = name;
       m_value = value;
     }
  
  
  
  1.4       +2 -2      xml-xalan/java/src/org/apache/xalan/stree/AttrImplNS.java
  
  Index: AttrImplNS.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/AttrImplNS.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AttrImplNS.java   2000/08/01 04:44:18     1.3
  +++ AttrImplNS.java   2000/10/09 23:25:16     1.4
  @@ -8,9 +8,9 @@
     private String m_localName;
     private String m_namespaceURI;                  // attribute index
     
  -  AttrImplNS(String uri, String name, String value)
  +  AttrImplNS(DocumentImpl doc, String uri, String name, String value)
     {
  -    super(name, value);
  +    super(doc, name, value);
       // System.out.println("AttrImplNS - name: "+name);
       // System.out.println("uri: "+uri+", "+name);
       m_namespaceURI = uri;
  
  
  
  1.3       +4 -4      
xml-xalan/java/src/org/apache/xalan/stree/CDATASectionImpl.java
  
  Index: CDATASectionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/CDATASectionImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CDATASectionImpl.java     2000/08/11 19:32:06     1.2
  +++ CDATASectionImpl.java     2000/10/09 23:25:16     1.3
  @@ -5,14 +5,14 @@
   
   public class CDATASectionImpl extends TextImpl implements CDATASection
   {
  -  public CDATASectionImpl (String data)
  +  public CDATASectionImpl (DocumentImpl doc, String data)
     {
  -    super(data);
  +    super(doc, data);
     }
   
  -  public CDATASectionImpl (char ch[], int start, int length)
  +  public CDATASectionImpl (DocumentImpl doc, char ch[], int start, int 
length)
     {
  -    super(ch, start, length);
  +    super(doc, ch, start, length);
     }
   
     /** Returns the node type. */
  
  
  
  1.8       +15 -21    xml-xalan/java/src/org/apache/xalan/stree/Child.java
  
  Index: Child.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/Child.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Child.java        2000/10/07 01:43:29     1.7
  +++ Child.java        2000/10/09 23:25:16     1.8
  @@ -16,7 +16,14 @@
   {
     private Parent m_parent;
     private short m_level;
  +  private DocumentImpl m_doc;
  +  protected void setDoc(DocumentImpl doc){m_doc = doc;}
     
  +  public Child(DocumentImpl doc)
  +  {
  +    m_doc = doc;
  +  }
  +  
     /**
      * Set the parent of the node.
      */
  @@ -38,17 +45,7 @@
     
     protected TransformerImpl getTransformer()
     {
  -    DocumentImpl di = this.getDocumentImpl();
  -    if(null != di)
  -    {
  -      SourceTreeHandler sth = di.getSourceTreeHandler();
  -      if(null != sth)
  -      {
  -        sth = di.getSourceTreeHandler();
  -        return sth.getTransformer();
  -      }
  -    }
  -    return null;
  +    return this.getDocumentImpl().getSourceTreeHandler().getTransformer();
     }
     
     /**
  @@ -58,8 +55,7 @@
      */
     protected Object getSynchObject()
     {
  -    Object obj = getTransformer();
  -    return (null == obj) ? this : obj;
  +    return this.getDocumentImpl().getSourceTreeHandler().getSynchObject();
     }
     
     protected void throwParseError(Exception e)
  @@ -79,6 +75,7 @@
       }
     }
     
  +  
     /**
      * The position in the parent's list.
      */
  @@ -147,18 +144,13 @@
      * Get the root Document Implementation.
      */
     DocumentImpl getDocumentImpl()
  -  {
    Child n = this;
    while(n.getUid() > 1)
  -    {
  -      n = (Child)n.getParentNode();
  -      if(n == null)
  -        return null;
  -    }
  -    return (DocumentImpl)n;
  +  {
  +    return m_doc;
     }
   
     
     // ================ Node interface implementation ==============
  -      
  +        
     /**
      * The parent of this node. All nodes, except <code>Attr</code>, 
      * <code>Document</code>, <code>DocumentFragment</code>, 
  @@ -168,6 +160,8 @@
      * <code>null</code>.
      */
     public Node         getParentNode()
  {
  +    // if(null != m_parent)
  +    //  m_parent.waitForHaveParent();
       return this.m_parent;
  }
   
     /**
  
  
  
  1.3       +4 -4      
xml-xalan/java/src/org/apache/xalan/stree/CommentImpl.java
  
  Index: CommentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/CommentImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CommentImpl.java  2000/08/11 19:32:07     1.2
  +++ CommentImpl.java  2000/10/09 23:25:16     1.3
  @@ -5,14 +5,14 @@
   
   public class CommentImpl extends TextImpl implements Comment
   {
  -  public CommentImpl (String data)
  +  public CommentImpl (DocumentImpl doc, String data)
     {
  -    super(data);
  +    super(doc, data);
     }
   
  -  public CommentImpl (char ch[], int start, int length)
  +  public CommentImpl (DocumentImpl doc, char ch[], int start, int length)
     {
  -    super(ch, start, length);
  +    super(doc, ch, start, length);
     }
   
     /** 
  
  
  
  1.4       +1 -0      
xml-xalan/java/src/org/apache/xalan/stree/DocumentFragmentImpl.java
  
  Index: DocumentFragmentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/DocumentFragmentImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DocumentFragmentImpl.java 2000/08/11 23:54:56     1.3
  +++ DocumentFragmentImpl.java 2000/10/09 23:25:16     1.4
  @@ -7,6 +7,7 @@
   {
     public DocumentFragmentImpl()
     {
  +    super();
       setComplete(true);
     }
     
  
  
  
  1.8       +14 -8     
xml-xalan/java/src/org/apache/xalan/stree/DocumentImpl.java
  
  Index: DocumentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/DocumentImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DocumentImpl.java 2000/10/07 01:43:29     1.7
  +++ DocumentImpl.java 2000/10/09 23:25:16     1.8
  @@ -19,17 +19,23 @@
   {
     DocumentImpl()
     {
  +    super(null);
  +    setDoc(this);
          m_bUpIndexer = new LevelIndexer();
     }
   
     DocumentImpl(SourceTreeHandler sth)
     {
  +    super(null);
  +    setDoc(this);
          m_bUpIndexer = new LevelIndexer();
       m_sourceTreeHandler = sth;
     }
   
     DocumentImpl(DocumentType doctype)
     {
  +    super(null);
  +    setDoc(this);
       if(null != doctype)
         m_docType = (DocumentTypeImpl)doctype;
          m_bUpIndexer = new LevelIndexer();
  @@ -196,9 +202,9 @@
       throws DOMException
     {
       if (indexedLookup)
  -      return new IndexedElemImpl(tagName);
  +      return new IndexedElemImpl(this, tagName);
       else
  -      return new ElementImpl(tagName);
  +      return new ElementImpl(this, tagName);
     }
   
     /** Create a DocumentFragment. */
  @@ -210,13 +216,13 @@
     /** Create a Text node. */
     public Text               createTextNode(String data)
     {
  -    return new TextImpl(data);
  +    return new TextImpl(this, data);
     }
   
     /** Create a Comment node. */
     public Comment            createComment(String data)
     {
  -    return new CommentImpl(data);
  +    return new CommentImpl(this, data);
     }
   
     /** Create a CDATASection node. */
  @@ -224,7 +230,7 @@
       throws DOMException
   
     {
  -    return new CDATASectionImpl(data);
  +    return new CDATASectionImpl(this, data);
     }
   
     /** Create a ProcessingInstruction node. */
  @@ -233,7 +239,7 @@
       throws DOMException
   
     {
  -    return new ProcessingInstructionImpl(target, data);
  +    return new ProcessingInstructionImpl(this, target, data);
     }
   
     /** Unimplemented right now, but I should probably implement. */
  @@ -250,9 +256,9 @@
       throws DOMException
     {
       if (indexedLookup)
  -      return new IndexedElemWithNS(namespaceURI, qualifiedName);
  +      return new IndexedElemWithNS(this, namespaceURI, qualifiedName);
       else
  -      return new ElementImplWithNS(namespaceURI, qualifiedName);
  +      return new ElementImplWithNS(this, namespaceURI, qualifiedName);
       //return super.createElementNS(namespaceURI, qualifiedName);
     }
   
  
  
  
  1.4       +2 -1      
xml-xalan/java/src/org/apache/xalan/stree/DocumentTypeImpl.java
  
  Index: DocumentTypeImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/DocumentTypeImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DocumentTypeImpl.java     2000/08/11 23:54:57     1.3
  +++ DocumentTypeImpl.java     2000/10/09 23:25:16     1.4
  @@ -6,8 +6,9 @@
   
   public class DocumentTypeImpl extends Child implements DocumentType 
   {
  -  DocumentTypeImpl(String name)
  +  DocumentTypeImpl(DocumentImpl doc, String name)
     {
  +    super(doc);
       m_name = name;
     }
     
  
  
  
  1.15      +18 -10    
xml-xalan/java/src/org/apache/xalan/stree/ElementImpl.java
  
  Index: ElementImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/ElementImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ElementImpl.java  2000/10/07 01:43:29     1.14
  +++ ElementImpl.java  2000/10/09 23:25:16     1.15
  @@ -15,13 +15,15 @@
     private String m_name;
     private short attrsEnd = 0;
     
  -  ElementImpl (String name)
  +  ElementImpl (DocumentImpl doc, String name)
     {
  +    super(doc);
       m_name = name;    
     }
   
  -  ElementImpl (String name, Attributes atts)
  +  ElementImpl (DocumentImpl doc, String name, Attributes atts)
     {
  +    super(doc);
       m_name = name;
       setAttributes(atts);
     }
  @@ -87,11 +89,14 @@
     public AttrImpl getChildAttribute(int i)
       throws ArrayIndexOutOfBoundsException, NullPointerException
     {
  -    // wait?
  -    if (i < getAttrCount() && i >= 0) 
  -      return (AttrImpl)m_children[i];
  -    else
  -      return null;
  +    Object synchObj = getSynchObject();
  +    synchronized (synchObj)
  +    {
  +      if (i < getAttrCount() && i >= 0) 
  +        return (AttrImpl)m_children[i];
  +      else
  +        return null;
  +    }
     }
     
     /**
  @@ -217,11 +222,12 @@
       AttrImpl attrImpl;
       if(QName.isXMLNSDecl(name))
       {
  -      attrImpl = new NameSpaceDecl("http://www.w3.org/2000/xmlns/";, 
  +      attrImpl = new NameSpaceDecl(getDocumentImpl(),
  +                                   "http://www.w3.org/2000/xmlns/";, 
                                      name, "");
       }
       else
  -      attrImpl = new AttrImpl(name, "");
  +      attrImpl = new AttrImpl(getDocumentImpl(), name, "");
       boolean found = false;
       for (int i = 0; i < attrsEnd; i++)
       {
  @@ -250,7 +256,9 @@
       throws DOMException
     {
       // System.out.println("qualifiedName: "+qualifiedName);
  -    AttrImplNS attrImpl = new AttrImplNS(namespaceURI, qualifiedName, "");
  +    AttrImplNS attrImpl = new AttrImplNS(getDocumentImpl(), 
  +                                         namespaceURI, 
  +                                         qualifiedName, "");
       boolean found = false;
       for (int i = 0; i < attrsEnd; i++)
       {
  
  
  
  1.2       +4 -4      
xml-xalan/java/src/org/apache/xalan/stree/ElementImplWithNS.java
  
  Index: ElementImplWithNS.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/ElementImplWithNS.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ElementImplWithNS.java    2000/06/19 16:52:36     1.1
  +++ ElementImplWithNS.java    2000/10/09 23:25:16     1.2
  @@ -7,9 +7,9 @@
     private String m_localName;
     private String m_uri;
     
  -  ElementImplWithNS (String ns, String name)
  +  ElementImplWithNS (DocumentImpl doc, String ns, String name)
     {
  -    super(name);
  +    super(doc, name);
       int index = name.indexOf(':');
       if (index >0)
         m_localName = name.substring(index+1);
  @@ -18,10 +18,10 @@
       m_uri = ns;
     }
     
  -  ElementImplWithNS (String ns, String localName,
  +  ElementImplWithNS (DocumentImpl doc, String ns, String localName,
                        String name, Attributes atts)
     {
  -    super(name, atts);
  +    super(doc, name, atts);
       m_localName = localName;
       m_uri = ns;
     }
  
  
  
  1.2       +4 -4      
xml-xalan/java/src/org/apache/xalan/stree/IndexedElemImpl.java
  
  Index: IndexedElemImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/IndexedElemImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IndexedElemImpl.java      2000/06/19 16:52:36     1.1
  +++ IndexedElemImpl.java      2000/10/09 23:25:16     1.2
  @@ -14,14 +14,14 @@
     private short attrsEnd;
     private int m_index;
     
  -  IndexedElemImpl (String name)
  +  IndexedElemImpl (DocumentImpl doc, String name)
     {
  -    super(name);    
  +    super(doc, name);    
     }
   
  -  IndexedElemImpl (String name, Attributes atts)
  +  IndexedElemImpl (DocumentImpl doc, String name, Attributes atts)
     {
  -    super(name, atts);    
  +    super(doc, name, atts);    
     }
   
     /** 
  
  
  
  1.2       +4 -4      
xml-xalan/java/src/org/apache/xalan/stree/IndexedElemWithNS.java
  
  Index: IndexedElemWithNS.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/IndexedElemWithNS.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IndexedElemWithNS.java    2000/06/19 16:52:36     1.1
  +++ IndexedElemWithNS.java    2000/10/09 23:25:17     1.2
  @@ -8,15 +8,15 @@
     private String m_uri;
     private int m_index;
     
  -  IndexedElemWithNS (String ns, String name)
  +  IndexedElemWithNS (DocumentImpl doc, String ns, String name)
     {
  -    super(ns,name);    
  +    super(doc, ns,name);    
     }
     
  -  IndexedElemWithNS (String ns, String localName,
  +  IndexedElemWithNS (DocumentImpl doc, String ns, String localName,
                        String name, Attributes atts)
     {
  -    super(ns, localName, name, atts);    
  +    super(doc, ns, localName, name, atts);    
     }
     
     /** 
  
  
  
  1.2       +2 -2      
xml-xalan/java/src/org/apache/xalan/stree/NameSpaceDecl.java
  
  Index: NameSpaceDecl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/NameSpaceDecl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NameSpaceDecl.java        2000/07/06 02:28:09     1.1
  +++ NameSpaceDecl.java        2000/10/09 23:25:17     1.2
  @@ -2,9 +2,9 @@
   
   public class NameSpaceDecl extends AttrImplNS
   {
  -  NameSpaceDecl(String uri, String name, String value)
  +  NameSpaceDecl(DocumentImpl doc, String uri, String name, String value)
     {
  -    super(uri, name, value);
  +    super(doc, uri, name, value);
     }
     
     /**
  
  
  
  1.10      +29 -37    xml-xalan/java/src/org/apache/xalan/stree/Parent.java
  
  Index: Parent.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/Parent.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Parent.java       2000/10/07 01:43:29     1.9
  +++ Parent.java       2000/10/09 23:25:17     1.10
  @@ -12,6 +12,11 @@
   
   public class Parent extends Child
   {
  +  public Parent(DocumentImpl doc)
  +  {
  +    super(doc);
  +  }
  +  
     /**
      * The list of children.  For space conservation reasons, 
      * this list is resized everytime a child is added, and is 
  @@ -111,37 +116,34 @@
     public Child getChild(int i)
       throws ArrayIndexOutOfBoundsException, NullPointerException
     {
  -    // wait?
  -    
  -    Child child = ((null != m_children) && (i >= 0) && i < 
m_children.length) ?
  -           m_children[i] : null;
  -    if (child == null && !isComplete())
  -    {
  -      Object synchObj = getSynchObject();
  -      synchronized (synchObj)
  +      Child child = ((null != m_children) && (i >= 0) && i < 
m_children.length) ?
  +                    m_children[i] : null;
  +      if (child == null && !isComplete())
         {
  -        try
  +        Object synchObj = getSynchObject();
  +        synchronized (synchObj)
           {
  -          // System.out.println("Waiting... getChild " + i + " " + 
getNodeName());
  -          while (!isComplete())
  +          try
             {
  -            synchObj.wait();
  +            // System.out.println("Waiting... getChild " + i + " " + 
getNodeName());
  +            while (!isComplete())
  +            {
  +              synchObj.wait();
  +              throwIfParseError();
  +              // System.out.println("... gotChild " + i);
  +              child = ((null != m_children) && (i >= 0) && i < 
m_children.length) ?
  +                      m_children[i] : null;
  +              if(null != child)
  +                break;
  +            }
  +          }
  +          catch (InterruptedException e)
  +          {
               throwIfParseError();
  -            // System.out.println("... gotChild " + i);
  -            child = ((null != m_children) && (i >= 0) && i < 
m_children.length) ?
  -                    m_children[i] : null;
  -            if(null != child)
  -              break;
             }
  -        }
  -        catch (InterruptedException e)
  -        {
  -          throwIfParseError();
           }
  -      }
  -    }     
  -    return child;
  -      
  +      }  
  +      return child;
     }
     
     /**
  @@ -193,8 +195,8 @@
       }
       
       Child child = (Child)newChild;
  -    m_children[childCount] = child;
       child.SetChildPosition(childCount);
  +    m_children[childCount] = child;
   
       DocumentImpl doc;
       try
  @@ -221,7 +223,7 @@
       }
       child.setParent(this);
       child.setLevel((short)(getLevel() + 1));
  -       // getDocumentImpl().getLevelIndexer().insertNode(child);
  +    // getDocumentImpl().getLevelIndexer().insertNode(child);
       
       if((null != doc) && (Node.ELEMENT_NODE == child.getNodeType()))
       {
  @@ -254,17 +256,7 @@
             }
           }
         }
  -
       }
  -    if (newChild.getNodeType() != Node.ATTRIBUTE_NODE)
  -    {  
  -      // Notify anyone waiting for a child...
  -      synchronized (getSynchObject())
  -      {
  -        getSynchObject().notifyAll();
  -      }
  -    }
  -    
       return newChild;
     }  
   
  
  
  
  1.3       +2 -1      
xml-xalan/java/src/org/apache/xalan/stree/ProcessingInstructionImpl.java
  
  Index: ProcessingInstructionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/ProcessingInstructionImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProcessingInstructionImpl.java    2000/08/11 19:32:08     1.2
  +++ ProcessingInstructionImpl.java    2000/10/09 23:25:17     1.3
  @@ -12,8 +12,9 @@
     /**
      * Implement the processingInstruction event.
      */
  -  ProcessingInstructionImpl(String target, String data)
  +  ProcessingInstructionImpl(DocumentImpl doc, String target, String data)
     {
  +    super(doc);
       m_name = target;
       m_data = data;
     }
  
  
  
  1.10      +144 -57   
xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java
  
  Index: SourceTreeHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SourceTreeHandler.java    2000/10/07 01:43:29     1.9
  +++ SourceTreeHandler.java    2000/10/09 23:25:17     1.10
  @@ -36,7 +36,14 @@
       if (indexedLookup)
         m_root = new IndexedDocImpl();
       else
  -      m_root = new DocumentImpl(this);      
  +      m_root = new DocumentImpl(this);  
  +    
  +    String urlOfSource = transformer.getBaseURLOfSource();
  +    if(null == m_inputSource)
  +    {
  +      m_inputSource = new InputSource(urlOfSource);
  +    }
  +    
transformer.getXPathContext().getSourceTreeManager().putDocumentInCache(m_root, 
m_inputSource);
     }
   
     /**
  @@ -52,6 +59,14 @@
       return m_transformer;
     }
   
  +  Object getSynchObject()
  +  {
  +    if (null != m_transformer) 
  +      return m_transformer;
  +    else
  +      return this;
  +  }
  +
     private DOMBuilder m_sourceTreeHandler;
     
     private Document m_root; // Normally a Document
  @@ -116,51 +131,61 @@
     
     private void notifyWaiters()
     {
  -    if(null != m_transformer)
  -    {
  -      synchronized (m_transformer)
  -      {
  -        m_transformer.notifyAll();
  -      }
  +    Object synchObj = getSynchObject();
  +    synchronized (synchObj)
  +    {      
  +      synchObj.notifyAll();
       }
     }
     
  +    
     /**
      * Implement the startDocument event.
      */
     public void startDocument ()
       throws SAXException
     {    
  -    if(null == m_root)
  +    synchronized (getSynchObject())
       {
  -      if (indexedLookup)
  -        m_root = new IndexedDocImpl();
  -      else
  -        m_root = new DocumentImpl(this);      
  -    }
  -    ((DocumentImpl)m_root).setSourceTreeHandler(this);
  -    ((DocumentImpl)m_root).setUid(1);
  -    ((DocumentImpl)m_root).setLevel(new Integer(1).shortValue());
  -    ((DocumentImpl)m_root).setUseMultiThreading(getUseMultiThreading());
  +      if(null == m_root)
  +      {
  +        if (indexedLookup)
  +          m_root = new IndexedDocImpl();
  +        else
  +          m_root = new DocumentImpl(this);  
  +        if(null != m_transformer)
  +        {
  +          String urlOfSource = m_transformer.getBaseURLOfSource();
  +          if(null == m_inputSource)
  +          {
  +            m_inputSource = new InputSource(urlOfSource);
  +          }
  +          
m_transformer.getXPathContext().getSourceTreeManager().putDocumentInCache(m_root,
 m_inputSource);
  +        }
  +      }
  +      ((DocumentImpl)m_root).setSourceTreeHandler(this);
  +      ((DocumentImpl)m_root).setUid(1);
  +      ((DocumentImpl)m_root).setLevel(new Integer(1).shortValue());
  +      ((DocumentImpl)m_root).setUseMultiThreading(getUseMultiThreading());
   
  -    m_sourceTreeHandler = new StreeDOMBuilder(m_root);
  -    pushShouldStripWhitespace(false);    
  +      m_sourceTreeHandler = new StreeDOMBuilder(m_root);
  +      pushShouldStripWhitespace(false);    
  +
  +      m_sourceTreeHandler.startDocument();
  +      
  +    }
       if(m_useMultiThreading && (null != m_transformer))
       {
  -      /*
  -      if(null != m_inputSource)
  -        
m_transformer.getXPathContext().getSourceTreeManager().putDocumentInCache(m_root,
 m_inputSource);
  -      Thread t = new Thread(m_transformer);
  -      t.start();
  -      */
  -      //m_transformer.transformNode(m_root);
  +      if(m_transformer.isParserEventsOnMain())
  +      {
  +        m_transformer.setSourceTreeDocForThread(m_root);
  +        Thread t = new Thread(m_transformer);
  +        t.start();
  +      }
       }
   
  -    m_sourceTreeHandler.startDocument();
       notifyWaiters();
     }
  -  
  -  
   
     /**
      * Implement the endDocument event.
  @@ -168,15 +193,40 @@
     public void endDocument ()
       throws SAXException
     {
  -    ((Parent)m_root).setComplete(true);    
  -    m_sourceTreeHandler.endDocument();
  -    popShouldStripWhitespace();    
  -    
  -    if(!m_useMultiThreading && (null != m_transformer))
  +    Object synchObj = getSynchObject();
  +    synchronized (synchObj)
       {
  -      m_transformer.transformNode(m_root);
  +      ((Parent)m_root).setComplete(true);    
  +      m_sourceTreeHandler.endDocument();
  +      popShouldStripWhitespace();    
  +      
  +      if(!m_useMultiThreading && (null != m_transformer))
  +      {
  +        m_transformer.transformNode(m_root);
  +      }
       }
       notifyWaiters();
  +    
  +    if(m_useMultiThreading && (null != m_transformer))
  +    {
  +      // Since the transform is on the secondary thread, we 
  +      // can't really exit until it is done, so we wait...
  +      // System.out.println("m_transformer.isTransformDone():" + 
m_transformer.isTransformDone());
  +      while(!m_transformer.isTransformDone())
  +      {
  +        synchronized(synchObj)
  +        {
  +          try
  +          {
  +            // System.out.println("Waiting...");
  +            synchObj.wait();
  +          }
  +          catch(InterruptedException ie)
  +          {
  +          }
  +        }
  +      }
  +    }
     }
   
     /**
  @@ -186,8 +236,12 @@
                               String name, Attributes atts)
       throws SAXException
     {
  -    pushShouldStripWhitespace(getShouldStripWhitespace());
  -    m_sourceTreeHandler.startElement(ns, localName, name, atts);
  +    synchronized (getSynchObject())
  +    {
  +      pushShouldStripWhitespace(getShouldStripWhitespace());
  +      m_sourceTreeHandler.startElement(ns, localName, name, atts);
  +    }
  +
       notifyWaiters();
     }
   
  @@ -198,9 +252,13 @@
                             String name)
       throws SAXException
     {
  -    ((Parent)m_sourceTreeHandler.getCurrentNode()).setComplete(true);
  -    m_sourceTreeHandler.endElement(ns, localName, name);
  -    popShouldStripWhitespace(); 
  +    synchronized (getSynchObject())
  +    {
  +      ((Parent)m_sourceTreeHandler.getCurrentNode()).setComplete(true);
  +      m_sourceTreeHandler.endElement(ns, localName, name);
  +      popShouldStripWhitespace(); 
  +    }
  +
       notifyWaiters();
     }
   
  @@ -239,11 +297,14 @@
      */
     private boolean isWhitespaceArray(char ch[], int start, int length)
     {
  -    int n = start+length;
  -    for(int i = start; i < n; i++)
  +    synchronized (getSynchObject())
       {
  -      if(!Character.isWhitespace(ch[i]))
  -         return false;
  +      int n = start+length;
  +      for(int i = start; i < n; i++)
  +      {
  +        if(!Character.isWhitespace(ch[i]))
  +          return false;
  +      }
       }
       return true;
     }
  @@ -254,13 +315,16 @@
     public void characters (char ch[], int start, int length)
       throws SAXException
     {
  -    if(isWhitespaceArray(ch, start, length) && getShouldStripWhitespace())
  -      return;
  -    
  -    if(m_isCData)
  -      m_sourceTreeHandler.cdata(ch, start, length);
  -    else
  -      m_sourceTreeHandler.characters(ch, start, length);
  +    synchronized (getSynchObject())
  +    {
  +      if(isWhitespaceArray(ch, start, length) && getShouldStripWhitespace())
  +        return;
  +      
  +      if(m_isCData)
  +        m_sourceTreeHandler.cdata(ch, start, length);
  +      else
  +        m_sourceTreeHandler.characters(ch, start, length);
  +    }
       notifyWaiters();
     }
   
  @@ -270,7 +334,10 @@
     public void charactersRaw (char ch[], int start, int length)
       throws SAXException
     {
  -    m_sourceTreeHandler.charactersRaw(ch, start, length);
  +    synchronized (getSynchObject())
  +    {
  +      m_sourceTreeHandler.charactersRaw(ch, start, length);
  +    }
       notifyWaiters();
     }
   
  @@ -280,7 +347,10 @@
     public void ignorableWhitespace (char ch[], int start, int length)
       throws SAXException
     {
  -    m_sourceTreeHandler.charactersRaw(ch, start, length);
  +    synchronized (getSynchObject())
  +    {
  +      m_sourceTreeHandler.charactersRaw(ch, start, length);
  +    }
       notifyWaiters();
     }
   
  @@ -290,7 +360,10 @@
     public void processingInstruction (String target, String data)
       throws SAXException
     {
  -    m_sourceTreeHandler.processingInstruction(target, data);
  +    synchronized (getSynchObject())
  +    {
  +      m_sourceTreeHandler.processingInstruction(target, data);
  +    }
       notifyWaiters();
     }
   
  @@ -309,7 +382,10 @@
     public void comment (char ch[], int start, int length)
       throws SAXException
     {
  -    m_sourceTreeHandler.comment(ch, start, length);
  +    synchronized (getSynchObject())
  +    {
  +      m_sourceTreeHandler.comment(ch, start, length);
  +    }
       notifyWaiters();
     }
     
  @@ -335,7 +411,10 @@
     public void startEntity (String name)
       throws SAXException
     {
  -    m_sourceTreeHandler.startEntity(name);
  +    synchronized (getSynchObject())
  +    {
  +      m_sourceTreeHandler.startEntity(name);
  +    }
       notifyWaiters();
     }
   
  @@ -349,7 +428,10 @@
     public void endEntity (String name)
       throws SAXException
     {
  -    m_sourceTreeHandler.endEntity(name);
  +    synchronized (getSynchObject())
  +    {
  +      m_sourceTreeHandler.endEntity(name);
  +    }
       notifyWaiters();
     }
     
  @@ -421,6 +503,10 @@
     public void startPrefixMapping (String prefix, String uri)
       throws SAXException
     {
  +    synchronized (getSynchObject())
  +    {
  +      m_sourceTreeHandler.startPrefixMapping(prefix, uri);
  +    }
       // System.out.println("DOMBuilder.startPrefixMapping("+prefix+", 
"+uri+");");
     }
   
  @@ -441,6 +527,7 @@
     public void endPrefixMapping (String prefix)
       throws SAXException
     {
  +    m_sourceTreeHandler.endPrefixMapping(prefix);
     }
     
     /**
  
  
  
  1.3       +4 -2      xml-xalan/java/src/org/apache/xalan/stree/TextImpl.java
  
  Index: TextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/TextImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TextImpl.java     2000/08/11 19:32:08     1.2
  +++ TextImpl.java     2000/10/09 23:25:17     1.3
  @@ -7,13 +7,15 @@
   {
     private String m_data;
    
  -  public TextImpl (String data)
  +  public TextImpl (DocumentImpl doc, String data)
     {
  +    super(doc);
       m_data = data;
     }
   
  -  public TextImpl (char ch[], int start, int length)
  +  public TextImpl (DocumentImpl doc, char ch[], int start, int length)
     {
  +    super(doc);
       m_data = new String(ch, start, start+length);
     }
     
  
  
  
  1.3       +2 -1      xml-xalan/java/src/org/apache/xalan/stree/WhiteSpace.java
  
  Index: WhiteSpace.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/WhiteSpace.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WhiteSpace.java   2000/08/11 19:32:09     1.2
  +++ WhiteSpace.java   2000/10/09 23:25:17     1.3
  @@ -12,8 +12,9 @@
   {
     String m_data;
     
  -  public WhiteSpace (char ch[], int start, int length)
  +  public WhiteSpace (DocumentImpl doc, char ch[], int start, int length)
     {
  +    super(doc);
       m_data = new String(ch, start, start+length);
     }
     
  
  
  
  1.9       +4 -3      
xml-xalan/java/src/org/apache/xalan/templates/FuncDocument.java
  
  Index: FuncDocument.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/FuncDocument.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FuncDocument.java 2000/10/06 07:55:33     1.8
  +++ FuncDocument.java 2000/10/09 23:25:19     1.9
  @@ -219,7 +219,7 @@
     {
       // System.out.println("base: "+base+", uri: "+uri);
       SourceTreeManager treeMgr = xctxt.getSourceTreeManager();
  -    Node newDoc = treeMgr.findNodeFromURL(base, uri);
  +    Node newDoc = treeMgr.findNodeFromURL(base, uri, xctxt.getSAXLocator());
       if(null != newDoc)
         return newDoc;
   
  @@ -232,7 +232,7 @@
       {
         if((null != uri) && (uri.toString().length() > 0))
         {
  -        newDoc = treeMgr.getSourceTree(base, uri);
  +        newDoc = treeMgr.getSourceTree(base, uri, xctxt.getSAXLocator());
           // System.out.println("newDoc: 
"+((Document)newDoc).getDocumentElement().getNodeName());
         }
         else
  @@ -343,7 +343,8 @@
     {
       String formattedMsg = XSLMessages.createWarning(msg, args);
       
  -    ErrorHandler errHandler = xctxt.getPrimaryReader().getErrorHandler();
  +    ErrorHandler errHandler = (null != xctxt.getPrimaryReader()) ? 
  +                              xctxt.getPrimaryReader().getErrorHandler() : 
null;
       TransformException te = new TransformException(formattedMsg, 
                                                      xctxt.getSAXLocator());
                                                      
  
  
  
  1.30      +219 -124  
xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- TransformerImpl.java      2000/10/06 20:21:17     1.29
  +++ TransformerImpl.java      2000/10/09 23:25:20     1.30
  @@ -194,14 +194,25 @@
      */
     public void reset()
     {
  -    m_stylesheetRoot = null;
  -    // m_rootDoc = null;
  -    // if(null != m_countersTable)
  -    //  System.out.println("Number counters made: 
"+m_countersTable.m_countersMade);
  +    // I need to look more carefully at which of these really
  +    // needs to be reset.
  +    
       m_countersTable = null;
  -    // m_resultNameSpaces = new Stack();
       m_stackGuard = new StackGuard();
       getXPathContext().reset();
  +    m_currentTemplateElements = new Stack();
  +    m_currentNodes = new Stack();
  +    m_currentMatchTemplates = new Stack();
  +    m_currentMatchNodes = new Stack();
  +    m_resultTreeHandler = new ResultTreeHandler(this);
  +    m_keyManager = new KeyManager();
  +    m_attrSetStack = null;
  +    m_countersTable = null;
  +    m_currentTemplateRuleIsNull = new BoolStack();
  +    m_xmlSource = null;
  +    m_doc = null;
  +    m_isTransformDone = false;
  +    m_inputContentHandler = null;
     }
         
     // ========= Transformer Interface Implementation ==========
  @@ -224,151 +235,191 @@
     }
     
     /**
  +   * True if the parser events should be on the main thread, 
  +   * false if not.  Experemental.  Can not be set right now.
  +   */
  +  private boolean m_parserEventsOnMain = true;
  +  
  +  /**
  +   * Get true if the parser events should be on the main thread, 
  +   * false if not.  Experemental.  Can not be set right now.
  +   */
  +  public boolean isParserEventsOnMain()
  +  {
  +    return m_parserEventsOnMain;
  +  }
  +    
  +  /**
      * Process the source tree to SAX parse events.
      * @param xmlSource  The input for the source tree.
      */
     public void transform( InputSource xmlSource)
       throws TransformException
     {
  -    String liaisonClassName = 
System.getProperty("org.apache.xalan.source.liaison");
  -
  -    if(null != liaisonClassName)
  +    if(null != xmlSource.getSystemId())
  +      m_urlOfSource = xmlSource.getSystemId();
  +    try
       {
  -      try 
  -      {
  -        DOM2Helper liaison =  
(DOM2Helper)(Class.forName(liaisonClassName).newInstance());
  -        liaison.parse(xmlSource);
  -        getXPathContext().setDOMHelper(liaison);
  -        transformNode(liaison.getDocument());
  -      } 
  -      catch (SAXException se) 
  +      // Get an already set XMLReader, or create one.
  +      XMLReader reader = this.getParent();
  +      if(null == reader)
         {
  -        if(se instanceof trax.TransformException)
  -          throw (trax.TransformException)se;
  -        else
  -          throw new TransformException(se);
  -      } 
  -      catch (ClassNotFoundException e1) 
  -      {
  -        throw new TransformException("XML Liaison class " + liaisonClassName 
+
  -          " specified but not found", e1);
  -      } 
  -      catch (IllegalAccessException e2) 
  -      {
  -          throw new TransformException("XML Liaison class " + 
liaisonClassName +
  -            " found but cannot be loaded", e2);
  -      } 
  -      catch (InstantiationException e3) 
  -      {
  -          throw new TransformException("XML Liaison class " + 
liaisonClassName +
  -            " loaded but cannot be instantiated (no empty public 
constructor?)",
  -            e3);
  -      } 
  -      catch (ClassCastException e4) 
  -      {
  -          throw new TransformException("XML Liaison class " + 
liaisonClassName +
  -            " does not implement DOM2Helper", e4);
  +        reader = XMLReaderFactory.createXMLReader();
         }
  -    }
  -    else
  -    {
         try
         {
  -        // Get an already set XMLReader, or create one.
  -        XMLReader reader = this.getParent();
  -        if(null == reader)
  -        {
  -          reader = XMLReaderFactory.createXMLReader();
  -        }
  -        try
  -        {
  -          
reader.setFeature("http://xml.org/sax/features/namespace-prefixes";, true);
  -        }
  -        catch(SAXException se)
  -        {
  -          // What can we do?
  -          // TODO: User diagnostics.
  -        }
  -        try
  -        {
  -          
reader.setFeature("http://apache.org/xml/features/validation/dynamic";, true);
  -        }
  -        catch(SAXException se)
  -        {
  -        }
  -        
  -        // Get the input content handler, which will handle the 
  -        // parse events and create the source tree. 
  -        ContentHandler inputHandler = getInputContentHandler();
  -        reader.setContentHandler( inputHandler );
  -        reader.setProperty("http://xml.org/sax/properties/lexical-handler";, 
inputHandler);
  -                
  -        // Set the reader for cloning purposes.
  -        getXPathContext().setPrimaryReader(reader);
  -        this.m_exceptionThrown = null;
  -        if(inputHandler instanceof org.apache.xalan.stree.SourceTreeHandler)
  +        reader.setFeature("http://xml.org/sax/features/namespace-prefixes";, 
true);
  +        
reader.setFeature("http://apache.org/xml/features/validation/dynamic";, true);
  +      }
  +      catch(SAXException se)
  +      {
  +        // What can we do?
  +        // TODO: User diagnostics.
  +      }
  +      
  +      // Get the input content handler, which will handle the 
  +      // parse events and create the source tree. 
  +      ContentHandler inputHandler = getInputContentHandler();
  +      reader.setContentHandler( inputHandler );
  +      reader.setProperty("http://xml.org/sax/properties/lexical-handler";, 
inputHandler);
  +      
  +      // Set the reader for cloning purposes.
  +      getXPathContext().setPrimaryReader(reader);
  +      this.m_exceptionThrown = null;
  +      if(inputHandler instanceof org.apache.xalan.stree.SourceTreeHandler)
  +      {
  +        
((org.apache.xalan.stree.SourceTreeHandler)inputHandler).setInputSource(xmlSource);
  +        
((org.apache.xalan.stree.SourceTreeHandler)inputHandler).setUseMultiThreading(true);
  +        Node doc 
  +          = 
((org.apache.xalan.stree.SourceTreeHandler)inputHandler).getRoot();
  +        if(null != doc)
           {
  -          
((org.apache.xalan.stree.SourceTreeHandler)inputHandler).setInputSource(xmlSource);
  -          
((org.apache.xalan.stree.SourceTreeHandler)inputHandler).setUseMultiThreading(true);
  -          Node doc 
  -            = 
((org.apache.xalan.stree.SourceTreeHandler)inputHandler).getRoot();
  -          if(null != doc)
  +          getXPathContext().getSourceTreeManager().putDocumentInCache(doc, 
xmlSource);
  +          
  +          m_xmlSource = xmlSource;
  +          m_doc = doc;
  +          
  +          if(isParserEventsOnMain())
             {
  -            getXPathContext().getSourceTreeManager().putDocumentInCache(doc, 
xmlSource);
  -            m_xmlSource = xmlSource;
  +            m_isTransformDone = false;
  +            getXPathContext().getPrimaryReader().parse(xmlSource);
  +          }
  +          else
  +          {
               Thread t = new Thread(this);
               t.start();
               transformNode(doc);
             }
  -          
           }
  -        else
  -        {
  -          // ??
  -          reader.parse( xmlSource );
  -        }
  -        
  -        // Kick off the parse.  When the ContentHandler gets 
  -        // the startDocument event, it will call transformNode( node ).
  -        // reader.parse( xmlSource );
           
  -        // This has to be done to catch exceptions thrown from 
  -        // the transform thread spawned by the STree handler.
  -        Exception e = getExceptionThrown();
  -        if(null != e)
  -        {
  -          if(e instanceof trax.TransformException)
  -            throw (trax.TransformException)e;
  -          else if(e instanceof 
org.apache.xalan.utils.WrappedRuntimeException)
  -            throw new trax.TransformException(
  -              
((org.apache.xalan.utils.WrappedRuntimeException)e).getException());
  -         else
  -            throw new trax.TransformException(e);
  -        }
         }
  -      catch(org.apache.xalan.utils.WrappedRuntimeException wre)
  +      else
         {
  -        Throwable throwable = wre.getException();
  -        while(throwable instanceof 
org.apache.xalan.utils.WrappedRuntimeException)
  -          throwable = 
((org.apache.xalan.utils.WrappedRuntimeException)throwable).getException();
  -        throw new TransformException(wre.getException());
  +        // ??
  +        reader.parse( xmlSource );
         }
  -      catch(SAXException se)
  -      {
  -        // se.printStackTrace();
  -        if(se instanceof TransformException)
  -          throw (TransformException)se;
  +      
  +      // Kick off the parse.  When the ContentHandler gets 
  +      // the startDocument event, it will call transformNode( node ).
  +      // reader.parse( xmlSource );
  +      
  +      // This has to be done to catch exceptions thrown from 
  +      // the transform thread spawned by the STree handler.
  +      Exception e = getExceptionThrown();
  +      if(null != e)
  +      {
  +        if(e instanceof trax.TransformException)
  +          throw (trax.TransformException)e;
  +        else if(e instanceof org.apache.xalan.utils.WrappedRuntimeException)
  +          throw new trax.TransformException(
  +            
((org.apache.xalan.utils.WrappedRuntimeException)e).getException());
           else
  -          throw new TransformException(se);
  -      }
  -      catch(IOException ioe)
  -      {
  -        throw new TransformException(ioe);
  +          throw new trax.TransformException(e);
         }
       }
  +    catch(org.apache.xalan.utils.WrappedRuntimeException wre)
  +    {
  +      Throwable throwable = wre.getException();
  +      while(throwable instanceof 
org.apache.xalan.utils.WrappedRuntimeException)
  +        throwable = 
((org.apache.xalan.utils.WrappedRuntimeException)throwable).getException();
  +      throw new TransformException(wre.getException());
  +    }
  +    catch(SAXException se)
  +    {
  +      se.printStackTrace();
  +      if(se instanceof TransformException)
  +        throw (TransformException)se;
  +      else
  +        throw new TransformException(se);
  +    }
  +    catch(IOException ioe)
  +    {
  +      throw new TransformException(ioe);
  +    }
  +    finally
  +    {
  +      reset();
  +    }
  +  }
  +  
  +  private String m_urlOfSource = null;
  +  
  +  /**
  +   * Get the base URL of the source.
  +   */
  +  public String getBaseURLOfSource()
  +  {
  +    return m_urlOfSource;
  +  }
  +  
  +  /**
  +   * Get the value of a property.  Recognized properties are:
  +   *
  +   * <p>"http://xml.apache.org/xslt/sourcebase"; - the base URL for the 
  +   * source, which is needed when pure SAX ContentHandler transformation 
  +   * is to be done.</p>
  +   *
  +   * @param name The property name, which is a fully-qualified URI.
  +   * @exception org.xml.sax.SAXNotRecognizedException When the
  +   *            XMLReader does not recognize the property name.
  +   * @exception org.xml.sax.SAXNotSupportedException When the
  +   *            XMLReader recognizes the property name but 
  +   *            cannot set the requested value.
  +   */
  +  public Object getProperty (String name)
  +    throws SAXNotRecognizedException, SAXNotSupportedException
  +  {
  +    if(name.equals("http://xml.apache.org/xslt/sourcebase";))
  +      return name;
  +    else
  +      return super.getProperty (name);
     }
     
     /**
  +   * Set the value of a property.  Recognized properties are:
  +   *
  +   * <p>"http://xml.apache.org/xslt/sourcebase"; - the base URL for the 
  +   * source, which is needed when pure SAX ContentHandler transformation 
  +   * is to be done.</p>
  +   *
  +   * @param name The property name, which is a fully-qualified URI.
  +   * @param value The requested value for the property.
  +   * @exception org.xml.sax.SAXNotRecognizedException When the
  +   *            XMLReader does not recognize the property name.
  +   * @exception org.xml.sax.SAXNotSupportedException When the
  +   *            XMLReader recognizes the property name but 
  +   *            cannot set the requested value.
  +   */
  +  public void setProperty (String name, Object value)
  +    throws SAXNotRecognizedException, SAXNotSupportedException
  +  {
  +    if(name.equals("http://xml.apache.org/xslt/sourcebase";))
  +      m_urlOfSource = (String)value;
  +    else
  +      super.getProperty (name);
  +  }
  +  
  +  /**
      * Process the an input source to a DOM node.  FOR INTERNAL USE ONLY.
      * @param xmlSource  The input for the source tree.
      */
  @@ -378,6 +429,9 @@
       // Duplicate code from above... but slightly different.  
       // TODO: Work on this...
       
  +    if(null != xmlSource.getSystemId())
  +      m_urlOfSource = xmlSource.getSystemId();
  +    
       Node doc = null;
       String liaisonClassName = 
System.getProperty("org.apache.xalan.source.liaison");
   
  @@ -429,6 +483,7 @@
           try
           {
             
reader.setFeature("http://xml.org/sax/features/namespace-prefixes";, true);
  +          
reader.setFeature("http://apache.org/xml/features/validation/dynamic";, true);
           }
           catch(SAXException se)
           {
  @@ -1770,7 +1825,7 @@
     }
   
     /**
  -   * Is > 0 when we're processing a for-each
  +   * Is > 0 when we're processing a for-each.
      */
     private BoolStack m_currentTemplateRuleIsNull = new BoolStack();
     
  @@ -1900,8 +1955,28 @@
     }
     
     private InputSource m_xmlSource;
  +  private Node m_doc;
  +  
  +  /**
  +   * This is just a way to set the document for run().
  +   */
  +  public void setSourceTreeDocForThread(Node doc)
  +  {
  +    m_doc = doc;
  +  }
     
     /**
  +   * If the the transform is on the secondary thread, we 
  +   * need to know when it is done, so we can return.
  +   */
  +  boolean m_isTransformDone = false;
  +
  +  public boolean isTransformDone()
  +  {
  +    return m_isTransformDone;
  +  }
  +  
  +  /**
      * Run the transform thread.
      */
     public void run()
  @@ -1910,10 +1985,30 @@
       {
         // Node n = ((SourceTreeHandler)getInputContentHandler()).getRoot();
         // transformNode(n);
  -      getXPathContext().getPrimaryReader().parse(m_xmlSource);
  +      if(isParserEventsOnMain())
  +      {
  +        try
  +        {
  +          m_isTransformDone = false;
  +          transformNode(m_doc);
  +        }
  +        finally
  +        {
  +          m_isTransformDone = true;
  +          synchronized (this)
  +          {
  +            notifyAll();
  +          }
  +        }
  +      }
  +      else
  +      {
  +        getXPathContext().getPrimaryReader().parse(m_xmlSource);
  +      }
       }
       catch(Exception e)
       {
  +      m_isTransformDone = true;
         m_exceptionThrown = e;
         ; // should have already been reported via the error handler?
         synchronized (this)
  
  
  
  1.7       +23 -0     xml-xalan/java/src/org/apache/xalan/utils/DOMBuilder.java
  
  Index: DOMBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/utils/DOMBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DOMBuilder.java   2000/10/02 15:29:08     1.6
  +++ DOMBuilder.java   2000/10/09 23:25:20     1.7
  @@ -630,6 +630,29 @@
     public void startPrefixMapping (String prefix, String uri)
          throws SAXException
     {
  +    /*
  +    // Not sure if this is needed or wanted
  +    // Also, it fails in the stree.
  +    if((null != m_currentNode) 
  +       && (m_currentNode.getNodeType() == Node.ELEMENT_NODE))
  +    {
  +      String qname;
  +      if(((null != prefix) && (prefix.length() == 0))
  +         || (null == prefix))
  +        qname = "xmlns";
  +      else
  +        qname = "xmlns:"+prefix;
  +       
  +      Element elem = (Element)m_currentNode;
  +      String val = elem.getAttribute(qname);
  +      if(val == null)
  +      {
  +        elem.setAttributeNS("http://www.w3.org/XML/1998/namespace";, 
  +                            qname, uri);
  +      }
  +    }
  +    */
  +
     }
   
     /**
  
  
  
  1.7       +6 -0      
xml-xalan/java/src/org/apache/xalan/utils/SystemIDResolver.java
  
  Index: SystemIDResolver.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/utils/SystemIDResolver.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SystemIDResolver.java     2000/10/06 07:47:49     1.6
  +++ SystemIDResolver.java     2000/10/09 23:25:20     1.7
  @@ -80,6 +80,12 @@
         urlString = urlString.substring(5);
       }
       
  +    // This is probably a bad idea, we should at least check for quotes...
  +    if(null != base  && (base.indexOf('\\') > -1))
  +      base = base.replace('\\', '/');
  +    if(null != urlString  && (urlString.indexOf('\\') > -1))
  +      urlString = urlString.replace('\\', '/');
  +    
       URI uri;
       try
       {
  
  
  
  1.7       +1 -1      xml-xalan/java/src/org/apache/xalan/utils/TreeWalker.java
  
  Index: TreeWalker.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/utils/TreeWalker.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TreeWalker.java   2000/10/05 01:38:38     1.6
  +++ TreeWalker.java   2000/10/09 23:25:20     1.7
  @@ -76,7 +76,7 @@
     
     // ARGHH!!  JAXP Uses Xerces without setting the namespace processing to 
ON!
     // DOM2Helper m_dh = new DOM2Helper();
  -  DOMHelper m_dh = new DOM2Helper();
  +  protected DOMHelper m_dh = new DOM2Helper();
     
     /**
      * Get the ContentHandler used for the tree walk.
  
  
  
  1.9       +46 -118   xml-xalan/java/src/org/apache/xalan/xslt/Process.java
  
  Index: Process.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/Process.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Process.java      2000/10/06 07:50:12     1.8
  +++ Process.java      2000/10/09 23:25:21     1.9
  @@ -110,6 +110,7 @@
   import org.xml.sax.XMLReader;
   import org.xml.sax.helpers.ParserAdapter;
   import org.xml.sax.helpers.XMLReaderFactory;
  +import org.xml.sax.ContentHandler;
   
   // Needed DOM classes
   import org.w3c.dom.Node;
  @@ -145,7 +146,7 @@
       System.out.println(resbundle.getString("optionTS")); //"   [-TS (Trace 
each selection event.)]");
       System.out.println(resbundle.getString("optionTTC")); //"   [-TTC (Trace 
the template children as they are being processed.)]");
       System.out.println(resbundle.getString("optionTCLASS")); //"   [-TCLASS 
(TraceListener class for trace extensions.)]");
  -    System.out.println(resbundle.getString("optionVALIDATE")); //"   
[-VALIDATE (Set whether validation occurs.  Validation is off by default.)]");
  +    // System.out.println(resbundle.getString("optionVALIDATE")); //"   
[-VALIDATE (Set whether validation occurs.  Validation is off by default.)]");
       System.out.println(resbundle.getString("optionEDUMP")); //"   [-EDUMP 
{optional filename} (Do stackdump on error.)]");
       System.out.println(resbundle.getString("optionXML")); //"   [-XML (Use 
XML formatter and add XML header.)]");
       System.out.println(resbundle.getString("optionTEXT")); //"   [-TEXT (Use 
simple Text formatter.)]");
  @@ -204,14 +205,13 @@
         String outFileName = null;
         String dumpFileName = null;
         String xslFileName = null;
  -      String compiledStylesheetFileNameOut = null;
  -      String compiledStylesheetFileNameIn = null;
         String treedumpFileName = null;
         PrintTraceListener tracer = null;
         String outputType = null;
         String media = null;
         Vector params = new Vector();
         boolean quietConflictWarnings = false;
  +      boolean isSAX = false;
   
         for (int i = 0;  i < argv.length;  i ++)
         {
  @@ -290,22 +290,6 @@
               
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
 new Object[] {"-XSL"})); //"Missing argument for);
   
           }
  -        else if("-LXCIN".equalsIgnoreCase(argv[i]))
  -        {
  -          if ( i+1 < argv.length)
  -            compiledStylesheetFileNameIn = argv[++i];
  -          else
  -            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
 new Object[] {"-LXCIN"})); //"Missing argument for);
  -
  -        }
  -        else if("-LXCOUT".equalsIgnoreCase(argv[i]))
  -        {
  -          if ( i+1 < argv.length)
  -            compiledStylesheetFileNameOut = argv[++i];
  -          else
  -            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
 new Object[] {"-LXCOUT"})); //"Missing argument for);
  -
  -        }
           else if ("-PARAM".equalsIgnoreCase(argv[i]))
           {
             if ( i+2 < argv.length)
  @@ -351,6 +335,7 @@
           {
             setQuietMode = true;
           }
  +        /*
           else if("-VALIDATE".equalsIgnoreCase(argv[i]))
           {
             String shouldValidate;
  @@ -365,6 +350,7 @@
   
             // 
xmlProcessorLiaison.setUseValidation(shouldValidate.equalsIgnoreCase("yes"));
           }
  +        */
           else if("-DIAG".equalsIgnoreCase(argv[i]))
           {
             doDiag = true;
  @@ -381,6 +367,10 @@
           {
             outputType = "html";
           }
  +        else if("-SAX".equalsIgnoreCase(argv[i]))
  +        {
  +          isSAX = true;
  +        }      
           else if("-EDUMP".equalsIgnoreCase(argv[i]))
           {
             doStackDumpOnError = true;
  @@ -402,31 +392,8 @@
           {
             dumpWriter = new PrintWriter( new FileWriter(dumpFileName) );
           }
  -
  -        Templates stylesheet = null;
   
  -        if(null != compiledStylesheetFileNameIn)
  -        {
  -          try
  -          {
  -            FileInputStream fileInputStream
  -              = new FileInputStream(compiledStylesheetFileNameIn);
  -            ObjectInputStream objectInput
  -              = new ObjectInputStream(fileInputStream);
  -            stylesheet = (Templates)objectInput.readObject();
  -            objectInput.close();
  -          }
  -          catch(java.io.UnsupportedEncodingException uee)
  -          {
  -            stylesheet = null;
  -            // 
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_ENCODING_NOT_SUPPORTED,
 new Object[] {stylesheet.getOutputEncoding()})); //"Encoding not supported: 
"+stylesheet.m_encoding);
  -            // throw new 
XSLProcessorException(XSLMessages.createMessage(XSLTErrorResources.ER_ENCODING_NOT_SUPPORTED,
 new Object[] {stylesheet.getOutputEncoding()})); //"Encoding not supported: 
"+stylesheet.m_encoding);
  -          }
  -        }
  -        else if(null != xslFileName)
  -        {
  -          stylesheet = processor.process(new InputSource(xslFileName));
  -        }
  +        Templates stylesheet = processor.process(new 
InputSource(xslFileName));
   
           PrintWriter resultWriter;
   
  @@ -448,16 +415,6 @@
   
           if(null != stylesheet)
           {
  -          if(null != compiledStylesheetFileNameOut)
  -          {
  -            FileOutputStream compiledStylesheetOutputStream
  -              = new FileOutputStream(compiledStylesheetFileNameOut);
  -            ObjectOutputStream compiledStylesheetOutput
  -              = new ObjectOutputStream(compiledStylesheetOutputStream);
  -
  -            compiledStylesheetOutput.writeObject(stylesheet);
  -          }
  -
             Transformer transformer = stylesheet.newTransformer();
             
             // Override the output format?
  @@ -487,7 +444,36 @@
             
             if(null != inFileName)
             {
  -            transformer.transform(new InputSource(inFileName), new 
Result(outputStream));
  +            if(isSAX)
  +            {
  +              OutputFormat format = stylesheet.getOutputFormat();
  +              if(null != outputType)
  +                format.setMethod(outputType);
  +              Serializer serializer = 
SerializerFactory.getSerializer(format);
  +              serializer.setOutputStream(outputStream);
  +              transformer.setContentHandler(serializer.asContentHandler());
  +              
transformer.setProperty("http://xml.apache.org/xslt/sourcebase";,
  +                                      inFileName);
  +
  +              XMLReader reader = XMLReaderFactory.createXMLReader();
  +              
  +              
reader.setFeature("http://xml.org/sax/features/namespace-prefixes";, true);
  +              
reader.setFeature("http://apache.org/xml/features/validation/dynamic";, true);
  +              
  +              ContentHandler chandler = transformer.getInputContentHandler();
  +              reader.setContentHandler(chandler);
  +              
  +              if(chandler instanceof org.xml.sax.ext.LexicalHandler)
  +                
reader.setProperty("http://xml.org/sax/properties/lexical-handler";, chandler);
  +              else
  +                
reader.setProperty("http://xml.org/sax/properties/lexical-handler";, null);
  +
  +              reader.parse(inFileName);
  +            }
  +            else
  +            {
  +              transformer.transform(new InputSource(inFileName), new 
Result(outputStream));
  +            }
             }
             else
             {
  @@ -515,70 +501,12 @@
              )
             doStackDumpOnError = true;
           
  -        if(throwable instanceof SAXException)
  -        {
  -          SAXException spe = (SAXException)throwable;
  -          if(doStackDumpOnError)
  -          {
  -            Exception containedException = spe.getException();
  -            if(null != containedException)
  -            {
  -              containedException = spe;
  -              while(containedException instanceof SAXException)
  -              {
  -                containedException.printStackTrace(dumpWriter);
  -                containedException = 
((SAXException)containedException).getException();
  -                dumpWriter.println("====================");
  -              }
  -              if(null != containedException)
  -              {
  -                containedException.printStackTrace(dumpWriter);
  -                dumpWriter.println("====================");
  -              }
  -              // else
  -              //  System.out.println("Error! "+se.getMessage());
  -              
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL,
 null)); //"XSL Process was not successful.");
  -            }
  -            else
  -            {
  -              spe.printStackTrace(dumpWriter);
  -            }
  -          }
  -          else
  -          {
  -            Exception e = spe;
  -            while(null != e)
  -            {
  -              if(null != e.getMessage())
  -              {
  -                
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_XSLT_ERROR,
 null)
  -                                    +" ("+e.getClass().getName()+"): " 
  -                                    + e.getMessage());        
  -              }
  -              if(e instanceof SAXParseException)
  -              {
  -                SAXParseException spe2 = (SAXParseException)e;
  -                if(null != spe2.getSystemId())
  -                  diagnosticsWriter.println("   ID: "+spe2.getSystemId()
  -                                            +" Line #"+spe2.getLineNumber()
  -                                            +" Column 
#"+spe2.getColumnNumber());
  -                e = spe2.getException();
  -                if(e instanceof 
org.apache.xalan.utils.WrappedRuntimeException)
  -                  e = 
((org.apache.xalan.utils.WrappedRuntimeException)e).getException();
  -              }
  -              else
  -                e = null;
  -            }
  -          }
  -        }      
  -        else 
  -        {
  -          
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_XSLT_ERROR,
 null)
  -                                    +" ("+throwable.getClass().getName()+"): 
" 
  -                                    + throwable.getMessage());        
  -          if(doStackDumpOnError)
  -            throwable.printStackTrace(dumpWriter);
  -        }
  +        
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_XSLT_ERROR,
 null)
  +                                  +" ("+throwable.getClass().getName()+"): " 
  +                                  + throwable.getMessage());        
  +        if(doStackDumpOnError)
  +          throwable.printStackTrace(dumpWriter);
  +        
           
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL,
 null)); //"XSL Process was not successful.");
           if(null != dumpFileName)
           {
  
  
  
  1.7       +30 -25    
xml-xalan/java/src/org/apache/xpath/SourceTreeManager.java
  
  Index: SourceTreeManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/SourceTreeManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SourceTreeManager.java    2000/10/06 07:53:16     1.6
  +++ SourceTreeManager.java    2000/10/09 23:25:21     1.7
  @@ -75,6 +75,7 @@
   import org.xml.sax.XMLReader;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.EntityResolver;
  +import org.xml.sax.Locator;
   
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xalan.stree.SourceTreeHandler;
  @@ -146,7 +147,7 @@
      * or a URI specified in the document() function.
      * @returns a InputSource that can be used to process the resource.
      */
  -  public InputSource resolveURI (String base, String urlString)
  +  public InputSource resolveURI (String base, String urlString, Locator 
locator)
       throws TransformException, IOException
     {
       String uri;
  @@ -166,11 +167,13 @@
           }
           catch(SAXException se2)
           {
  -          throw new TransformException(se2);
  +          throw new TransformException("URL of base: "+base+
  +          " and url: "+urlString+" can't be resolved", locator, se2);
           }
         }
         else
  -        throw new TransformException(se);
  +        throw new TransformException("URL of base: "+base+
  +          " and url: "+urlString+" can't be resolved", locator, se);
       }
       
       InputSource source;
  @@ -183,7 +186,8 @@
       }
       catch(SAXException se2)
       {
  -      throw new TransformException(se2);
  +      throw new TransformException("URL: "+urlString
  +        +" can't be resolved", locator, se2);
       }
   
       return source;
  @@ -207,12 +211,12 @@
      * Given a URL, find the node associated with that document.
      * @param url 
      */
  -  public Node findNodeFromURL(String base, String url)
  +  public Node findNodeFromURL(String base, String url, Locator locator)
       throws TransformException
     {
       try
       {
  -      InputSource source = this.resolveURI(base, url);
  +      InputSource source = this.resolveURI(base, url, locator);
         if(null != source.getSystemId())
           url = source.getSystemId();
         Node node = null;
  @@ -230,39 +234,39 @@
       }
       catch(IOException ioe)
       {
  -      throw new TransformException(ioe);
  +      throw new TransformException(ioe, locator);
       }
     }
     
     /**
      * Get the source tree from the a base URL and a URL string.
      */
  -  public Node getSourceTree (String base, String urlString) 
  +  public Node getSourceTree (String base, String urlString, Locator locator) 
       throws TransformException
     {
       try
       {
  -      InputSource source = this.resolveURI(base, urlString);
  +      InputSource source = this.resolveURI(base, urlString, locator);
         // System.out.println("base: "+base+", urlString: "+urlString+", 
source: "+source.getSystemId());
  -      return getSourceTree(source);
  +      return getSourceTree(source, locator);
       }
       catch(IOException ioe)
       {
  -      throw new TransformException(ioe);
  +      throw new TransformException(ioe, locator);
       }
     }
   
     /**
      * Get the source tree from the input source.
      */
  -  public Node getSourceTree (InputSource source) 
  +  public Node getSourceTree (InputSource source, Locator locator) 
       throws TransformException
     {
       // Try first to see if we have a node cached that matches this 
       // systemID.
       if(null != source.getSystemId())
       {
  -      Node n = findNodeFromURL(null, source.getSystemId());
  +      Node n = findNodeFromURL(null, source.getSystemId(), locator);
         if(null != n)
           return n;
       }
  @@ -273,7 +277,7 @@
         root = m_uriResolver.getDOMNode(source);
       
       if(null == root)
  -      root = getDOMNode(source);
  +      root = getDOMNode(source, locator);
       
       if(null != root)
         putDocumentInCache(root, source);
  @@ -283,7 +287,7 @@
     /**
      * Try to create a DOM source tree from the input source.
      */
  -  public Node getDOMNode (InputSource source) 
  +  public Node getDOMNode (InputSource source, Locator locator) 
       throws TransformException
     {
       Node doc = null;
  @@ -299,35 +303,35 @@
         } 
         catch (SAXException se) 
         {
  -        throw new TransformException(se);
  +        throw new TransformException(se, locator);
         } 
         catch (ClassNotFoundException e1) 
         {
           throw new TransformException("XML Liaison class " + liaisonClassName 
+
  -          " specified but not found", e1);
  +          " specified but not found", locator, e1);
         } 
         catch (IllegalAccessException e2) 
         {
             throw new TransformException("XML Liaison class " + 
liaisonClassName +
  -            " found but cannot be loaded", e2);
  +            " found but cannot be loaded", locator, e2);
         } 
         catch (InstantiationException e3) 
         {
             throw new TransformException("XML Liaison class " + 
liaisonClassName +
               " loaded but cannot be instantiated (no empty public 
constructor?)",
  -            e3);
  +            locator, e3);
         } 
         catch (ClassCastException e4) 
         {
             throw new TransformException("XML Liaison class " + 
liaisonClassName +
  -            " does not implement DOM2Helper", e4);
  +            " does not implement DOM2Helper", locator, e4);
         }
       }
       else
       {
       try
       {
  -      XMLReader reader = getXMLReader(source) ;
  +      XMLReader reader = getXMLReader(source, locator) ;
         
         // TODO: Need to use factory of some kind to create the ContentHandler
         // (Also, try using JAXP if need be...)
  @@ -355,11 +359,11 @@
       }
       catch(IOException ioe)
       {
  -      throw new TransformException(ioe);
  +      throw new TransformException(ioe, locator);
       }
       catch(SAXException se)
       {
  -      throw new TransformException(se);
  +      throw new TransformException(se, locator);
       }
       }
       return doc;
  @@ -376,7 +380,7 @@
      * @param inputSource The value returned from the EntityResolver.
      * @returns a SAX2 parser to use with the InputSource.
      */
  -  public XMLReader getXMLReader(InputSource inputSource) 
  +  public XMLReader getXMLReader(InputSource inputSource, Locator locator) 
       throws TransformException
     {
       try
  @@ -389,6 +393,7 @@
         try
         {
           reader.setFeature("http://xml.org/sax/features/namespace-prefixes";, 
true);
  +        
reader.setFeature("http://apache.org/xml/features/validation/dynamic";, true);
         }
         catch(SAXException se)
         {
  @@ -400,7 +405,7 @@
       }
       catch(SAXException se)
       {
  -      throw new TransformException(se);
  +      throw new TransformException(se, locator);
       }
     }
   }
  
  
  
  1.4       +2 -2      xml-xalan/java/src/org/apache/xpath/XPath.java
  
  Index: XPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPath.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XPath.java        2000/07/31 22:12:45     1.3
  +++ XPath.java        2000/10/09 23:25:21     1.4
  @@ -203,8 +203,8 @@
           throw (trax.TransformException)e;
         else
         {
  -        // System.out.println("m_locator.getSystemId(): 
"+m_locator.getSystemId());
  -        // System.out.println("m_locator.getLineNumber(): 
"+m_locator.getLineNumber());
  +        while(e instanceof org.apache.xalan.utils.WrappedRuntimeException)
  +          e = 
((org.apache.xalan.utils.WrappedRuntimeException)e).getException();
           throw new trax.TransformException("Error in XPath", m_locator, e);
         }
       }
  
  
  
  1.4       +1 -1      xml-xalan/java/src/org/apache/xpath/XPathContext.java
  
  Index: XPathContext.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathContext.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XPathContext.java 2000/10/05 01:38:38     1.3
  +++ XPathContext.java 2000/10/09 23:25:21     1.4
  @@ -311,7 +311,7 @@
       InputSource inputSource;
       try
       {
  -      inputSource = getSourceTreeManager().resolveURI(base, urlString);
  +      inputSource = getSourceTreeManager().resolveURI(base, urlString, 
getSAXLocator());
       }
       catch(IOException ioe)
       {
  
  
  
  1.7       +37 -41    xml-xalan/java/src/trax/Processor.java
  
  Index: Processor.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/trax/Processor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Processor.java    2000/10/04 18:28:58     1.6
  +++ Processor.java    2000/10/09 23:25:22     1.7
  @@ -117,6 +117,12 @@
     private static String platformDefaultFactoryName = null;
     
     /**
  +   * The name of the properties file used to get the trax.processor.xslt
  +   * property via getResourceAsStream.
  +   */
  +  public static String PropertiesResource = "trax.properties";
  +    
  +  /**
      * Set the name of the default concrete class to be used.
      * @param classname Full classname of concrete implementation 
      * of org.xml.trax.Processor.
  @@ -125,6 +131,23 @@
     {
       platformDefaultFactoryName = classname;
     }
  +  
  +  private static String getFactoryNameFromResourceStream(String factoryKey)
  +  {
  +    try
  +    {
  +      Properties props = new Properties();
  +      InputStream is = Processor.class.getResourceAsStream( 
PropertiesResource );
  +      if(null == is)
  +        return null;
  +      props.load( is );
  +      return props.getProperty ( factoryKey );
  +    }
  +    catch(IOException ioe)
  +    {
  +      return null;
  +    }
  +  }
       
     /**
      * Obtain a new instance of a Processor object.
  @@ -134,22 +157,31 @@
       throws ProcessorFactoryException
     {
       Processor factory = null;
  +    String factoryName;
       try
       {
         String factoryKey = "trax.processor."+type;
  -      String factoryName = System.getProperty(factoryKey);
  +      factoryName = null;
  +      try 
  +      {
  +        factoryName = System.getProperty(factoryKey);
  +      }
  +      catch (SecurityException e){}
         
         if(null == factoryName)
         {
  -        loadPropertyFileToSystem(XSLT_PROPERTIES) ;
  -        factoryName = System.getProperty(factoryKey);
  +        try
  +        {
  +          factoryName = getFactoryNameFromResourceStream(factoryKey);
  +        }
  +        catch (SecurityException e){}
         }
   
         if(null == factoryName)
           factoryName = platformDefaultFactoryName;
         
         if(null == factoryName)
  -        throw new ProcessorFactoryException("Can't find system property: 
"+factoryKey, null);
  +        throw new ProcessorFactoryException("Can't find trax property: 
"+factoryKey, null);
         
         Class factoryClass = Class.forName(factoryName);
         factory = (Processor)factoryClass.newInstance();
  @@ -168,44 +200,8 @@
       }
       
       return factory;
  -  }
  -  
  -  // TODO: This needs changing to some vendor neutral location.
  -  public static String XSLT_PROPERTIES = 
"/org/apache/xalan/res/XSLTInfo.properties";
  -  
  -  /*
  -  * Retrieve a propery bundle from a specified file and load it 
  -  * int the System properties.
  -  * @param file The string name of the property file.  
  -  */
  -  private static void loadPropertyFileToSystem(String file) 
  -  {
  -    InputStream is;
  -    try
  -    {                   
  -      Properties props = new Properties();
  -      is = Process.class.getResourceAsStream(file);    
  -      // get a buffered version
  -      BufferedInputStream bis = new BufferedInputStream (is);
  -      props.load (bis);                                     // and load up 
the property bag from this
  -      bis.close ();                                          // close out 
after reading
  -      // OK, now we only want to set system properties that 
  -      // are not already set.
  -      Properties systemProps = System.getProperties();
  -      Enumeration propEnum = props.propertyNames();
  -      while(propEnum.hasMoreElements())
  -      {
  -        String prop = (String)propEnum.nextElement();
  -        if(!systemProps.containsKey(prop))
  -          systemProps.put(prop, props.getProperty(prop));
  -      }
  -      System.setProperties(systemProps);
  -    }
  -    catch (Exception ex)
  -    {
  -    }
     }
  -  
  +      
     /**
      * Process the source into a templates object.
      * 
  
  
  
  1.4       +156 -0    xml-xalan/java/src/trax/ProcessorException.java
  
  Index: ProcessorException.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/trax/ProcessorException.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProcessorException.java   2000/09/19 21:04:59     1.3
  +++ ProcessorException.java   2000/10/09 23:25:22     1.4
  @@ -61,6 +61,7 @@
   package trax;
   
   import org.xml.sax.SAXParseException;
  +import org.xml.sax.SAXException;
   import org.xml.sax.Locator;
   import org.xml.sax.helpers.LocatorImpl;
   
  @@ -210,5 +211,160 @@
                                int lineNumber, int columnNumber, Exception e)
     {
       super(message, publicId, systemId, lineNumber, columnNumber, e);
  +  }
  +  
  +  
  +  /**
  +   * Print the the trace of methods from where the error 
  +   * originated.  This will trace all nested exception 
  +   * objects, as well as this object.
  +   * @param s The stream where the dump will be sent to.
  +   */
  +  public void printStackTrace(java.io.PrintStream s) 
  +  {
  +    if(s == null)
  +      s = System.err;
  +    try
  +    {
  +      super.printStackTrace(s);
  +    }
  +    catch(Exception e){}
  +    Exception exception = getException();
  +    for(int i = 0; (i < 10) && (null != exception); i++)
  +    {
  +      s.println("---------");
  +      exception.printStackTrace(s);
  +      if(exception instanceof SAXException)
  +      {
  +        SAXException se = (SAXException)exception;
  +        Exception prev = exception;
  +        exception = se.getException();
  +        if(prev == exception)
  +          break;
  +      }
  +      else
  +      {
  +        exception = null;
  +      }
  +    }
  +  }
  +  
  +  /**
  +   * Find the most contained message.
  +   * @returns The error message of the originating exception.
  +   */
  +  public String getMessage() 
  +  {
  +    StringBuffer sbuffer = new StringBuffer();
  +    
  +    if(null != super.getMessage())
  +    {
  +      sbuffer.append(super.getMessage());
  +    }
  +    if(null != getSystemId())
  +    {
  +      sbuffer.append("; SystemID: ");
  +      sbuffer.append(getSystemId());
  +    }
  +    if(0 != getLineNumber())
  +    {
  +      sbuffer.append("; Line#: ");
  +      sbuffer.append(getLineNumber());
  +    }
  +    if(0 != getColumnNumber())
  +    {
  +      sbuffer.append("; Column#: ");
  +      sbuffer.append(getColumnNumber());
  +    }
  +
  +    Exception exception = getException();
  +    while(null != exception)
  +    {
  +      if(null != exception.getMessage())
  +      {
  +        sbuffer.append("\n (");
  +        sbuffer.append( exception.getClass().getName());
  +        sbuffer.append( "): ");
  +        sbuffer.append(exception.getMessage());
  +      }
  +      
  +      if((!((exception instanceof TransformException) || 
  +           (exception instanceof ProcessorException))) &&
  +         (exception instanceof SAXException))
  +      {
  +        if(exception instanceof SAXParseException)
  +        {
  +          SAXParseException spe = (SAXParseException)exception;
  +          if(null != spe.getSystemId())
  +          {
  +            sbuffer.append("; SystemID: ");
  +            sbuffer.append(spe.getSystemId());
  +          }
  +          if(0 != spe.getLineNumber())
  +          {
  +            sbuffer.append("; Line#: ");
  +            sbuffer.append(spe.getLineNumber());
  +          }
  +          if(0 != spe.getColumnNumber())
  +          {
  +            sbuffer.append("; Column#: ");
  +            sbuffer.append(spe.getColumnNumber());
  +          }
  +        }
  +        SAXException se = (SAXException)exception;
  +        exception = se.getException();
  +      }
  +      else
  +      {
  +        exception = null;
  +      }
  +    }
  +    return sbuffer.toString();
  +  }
  +
  +  /**
  +   * Print the the trace of methods from where the error 
  +   * originated.  This will trace all nested exception 
  +   * objects, as well as this object.
  +   * @param s The writer where the dump will be sent to.
  +   */
  +  public void printStackTrace(java.io.PrintWriter s) 
  +  {
  +    if(s == null)
  +      s = new java.io.PrintWriter(System.err);
  +    try
  +    {
  +      super.printStackTrace(s);
  +    }
  +    catch(Exception e){}
  +    Exception exception = getException();
  +    
  +    for(int i = 0; (i < 10) && (null != exception); i++)
  +    {
  +      s.println("---------");
  +      try
  +      {
  +        exception.printStackTrace(s);
  +      }
  +      catch(Exception e)
  +      {
  +        s.println("Could not print stack trace...");
  +      }
  +      if(exception instanceof SAXException)
  +      {
  +        SAXException se = (SAXException)exception;
  +        Exception prev = exception;
  +        exception = se.getException();
  +        if(prev == exception)
  +        {
  +          exception = null;
  +          break;
  +        }
  +      }
  +      else
  +      {
  +        exception = null;
  +      }
  +    }
     }
   }
  
  
  
  1.3       +237 -4    xml-xalan/java/src/trax/TransformException.java
  
  Index: TransformException.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/trax/TransformException.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TransformException.java   2000/09/19 21:05:02     1.2
  +++ TransformException.java   2000/10/09 23:25:22     1.3
  @@ -61,6 +61,7 @@
   package trax;
   
   import org.xml.sax.SAXParseException;
  +import org.xml.sax.SAXException;
   import org.xml.sax.Locator;
   import org.xml.sax.helpers.LocatorImpl;
   
  @@ -96,8 +97,19 @@
      */
     public TransformException (Exception e)
     {
  -    super("TRaX Transform Exception", new LocatorImpl(), e);
  +    super(e.getMessage(), new LocatorImpl(), e);
     }
  +  
  +  /**
  +   * Create a new TransformException wrapping an existing exception.
  +   *
  +   * @param e The exception to be wrapped in a SAXException.
  +   * @see org.xml.sax.SAXException
  +   */
  +  public TransformException (Exception e, Locator locator)
  +  {
  +    super(e.getMessage(), locator, e);
  +  }
   
     /**
      * Wrap an existing exception in a TransformException.
  @@ -113,7 +125,7 @@
      */
     public TransformException (String message, Exception e) 
     {
  -    super( "TRaX Transform Exception", new LocatorImpl(), e);
  +    super( message, new LocatorImpl(), e);
     }
     
     /**
  @@ -133,7 +145,6 @@
       super(message, locator);
     }
     
  -  
     /**
      * Wrap an existing exception in a TransformException.
      *
  @@ -154,7 +165,7 @@
     {
       super( message, locator, e);
     }
  -    
  +  
     /**
      * Create a new TransformException.
      *
  @@ -210,5 +221,227 @@
     {
       super(message, publicId, systemId, lineNumber, columnNumber, e);
     }
  +  
  +  
  +  /**
  +   * Print the the trace of methods from where the error 
  +   * originated.  This will trace all nested exception 
  +   * objects, as well as this object.
  +   * @param s The stream where the dump will be sent to.
  +   */
  +  public void printStackTrace(java.io.PrintStream s) 
  +  {
  +    if(s == null)
  +      s = System.err;
  +    try
  +    {
  +      super.printStackTrace(s);
  +    }
  +    catch(Exception e){}
  +    Exception exception = getException();
  +    for(int i = 0; (i < 10) && (null != exception); i++)
  +    {
  +      s.println("---------");
  +      exception.printStackTrace(s);
  +      if(exception instanceof SAXException)
  +      {
  +        SAXException se = (SAXException)exception;
  +        Exception prev = exception;
  +        exception = se.getException();
  +        if(prev == exception)
  +          break;
  +      }
  +      else
  +      {
  +        exception = null;
  +      }
  +    }
  +  }
  +  
  +  private boolean isSimilar(Exception e1, Exception e2)
  +  {
  +    boolean isSimilar = false;
  +    if((e1 instanceof SAXParseException) && 
  +       (e2 instanceof SAXParseException))
  +    {
  +      // If the file and line number are the same, then only 
  +      // report the top-level error.
  +      SAXParseException spe1 = (SAXParseException)e1;
  +      String oldSystemID = spe1.getSystemId();
  +      int oldLine = spe1.getLineNumber();
  +      int oldColumn = spe1.getColumnNumber();
  +
  +      SAXParseException spe2 = (SAXParseException)e2;
  +      String newSystemID = spe2.getSystemId();
  +      int newLine = spe2.getLineNumber();
  +      int newColumn = spe2.getColumnNumber();
  +      
  +      if(oldSystemID == null)
  +        oldSystemID = "";
  +      if(newSystemID == null)
  +        newSystemID = "";
  +
  +      isSimilar = (oldSystemID.equals(newSystemID) 
  +                   && (oldLine == newLine)
  +                   && (oldColumn == newColumn));  
  +    }
  +    return isSimilar;
  +  }
  +  
  +  private void appendMessageAndInfo(StringBuffer sbuffer)
  +  {
  +    String message = super.getMessage();
  +    String systemID = getSystemId();
  +    int line = getLineNumber();
  +    int column = getColumnNumber();
  +    
  +    if(null != message)
  +    {
  +      sbuffer.append(message);
  +    }
  +    if(null != systemID)
  +    {
  +      sbuffer.append("; SystemID: ");
  +      sbuffer.append(systemID);
  +    }
  +    if(0 != line)
  +    {
  +      sbuffer.append("; Line#: ");
  +      sbuffer.append(line);
  +    }
  +    if(0 != column)
  +    {
  +      sbuffer.append("; Column#: ");
  +      sbuffer.append(column);
  +    }
  +  }
  +  
  +  /**
  +   * Find the most contained message.
  +   * @returns The error message of the originating exception.
  +   */
  +  public String getMessage() 
  +  {
  +    StringBuffer sbuffer = new StringBuffer();
  +    
  +    appendMessageAndInfo(sbuffer);
  +    
  +    Exception prev = this;
  +
  +    Exception exception = getException();
  +    while(null != exception)
  +    {      
  +      if((!((exception instanceof TransformException) || 
  +           (exception instanceof ProcessorException))) &&
  +         (exception instanceof SAXException))
  +      {
  +        if(exception instanceof SAXParseException)
  +        {          
  +          if(!isSimilar(prev, exception))
  +          {
  +            SAXParseException spe = (SAXParseException)exception;
  +            String message = spe.getMessage();
  +            if(null != message)
  +            {
  +              sbuffer.append("\n (");
  +              sbuffer.append( spe.getClass().getName());
  +              sbuffer.append( "): ");
  +              sbuffer.append(message);
  +            }
  +
  +            if(null != spe.getSystemId())
  +            {
  +              sbuffer.append("; SystemID: ");
  +              sbuffer.append(spe.getSystemId());
  +            }
  +            if(0 != spe.getLineNumber())
  +            {
  +              sbuffer.append("; Line#: ");
  +              sbuffer.append(spe.getLineNumber());
  +            }
  +            if(0 != spe.getColumnNumber())
  +            {
  +              sbuffer.append("; Column#: ");
  +              sbuffer.append(spe.getColumnNumber());
  +            }
  +          }
  +        }
  +        else if(!isSimilar(prev, exception))
  +        {
  +          String message = exception.getMessage();
  +          if(null != message)
  +          {
  +            sbuffer.append("\n (");
  +            sbuffer.append( exception.getClass().getName());
  +            sbuffer.append( "): ");
  +            sbuffer.append(message);
  +          }
  +        }
  +        
  +        prev = exception;
  +        exception = ((SAXException)exception).getException();
  +      }
  +      else if(!isSimilar(prev, exception))
  +      {
  +        String message = exception.getMessage();
  +        if(null != message)
  +        {
  +          sbuffer.append("\n (");
  +          sbuffer.append( exception.getClass().getName());
  +          sbuffer.append( "): ");
  +          sbuffer.append(message);
  +        }
  +        exception = null;
  +      }
  +    }
  +    return sbuffer.toString();
  +  }
  +
  +  /**
  +   * Print the the trace of methods from where the error 
  +   * originated.  This will trace all nested exception 
  +   * objects, as well as this object.
  +   * @param s The writer where the dump will be sent to.
  +   */
  +  public void printStackTrace(java.io.PrintWriter s) 
  +  {
  +    if(s == null)
  +      s = new java.io.PrintWriter(System.err);
  +    try
  +    {
  +      super.printStackTrace(s);
  +    }
  +    catch(Exception e){}
  +    Exception exception = getException();
  +    
  +    for(int i = 0; (i < 10) && (null != exception); i++)
  +    {
  +      s.println("---------");
  +      try
  +      {
  +        exception.printStackTrace(s);
  +      }
  +      catch(Exception e)
  +      {
  +        s.println("Could not print stack trace...");
  +      }
  +      if(exception instanceof SAXException)
  +      {
  +        SAXException se = (SAXException)exception;
  +        Exception prev = exception;
  +        exception = se.getException();
  +        if(prev == exception)
  +        {
  +          exception = null;
  +          break;
  +        }
  +      }
  +      else
  +      {
  +        exception = null;
  +      }
  +    }
  +  }
  +
   
   }
  
  
  
  1.4       +2 -9      xml-xalan/java/src/trax/trax.properties
  
  Index: trax.properties
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/trax/trax.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- trax.properties   2000/09/21 19:15:44     1.3
  +++ trax.properties   2000/10/09 23:25:22     1.4
  @@ -1,5 +1,5 @@
   #
  -# $Revision: 1.3 $ $Date: 2000/09/21 19:15:44 $
  +# $Revision: 1.4 $ $Date: 2000/10/09 23:25:22 $
   #
   # Note: This properties file is provided for illustrative purposes
   #       only and is not part of the interface definition.
  @@ -8,12 +8,5 @@
   #       implementation classes and output methods.
   #
   
  -#
  -# Lis the methods supported by this implementation
  -#
  -serialize.methods=xml,html,xhtml,text,wml:wml
  -
  -#
  -# Use the Xalan serializer implementation for the default XSLT processor
  -#
  +# The TRaX Stylesheet processor
   trax.processor.xslt=org.apache.xalan.processor.StylesheetProcessor
  
  
  

Reply via email to