You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mm...@apache.org on 2001/01/12 22:26:35 UTC

cvs commit: xml-xalan/java/compat_src/org/apache/xalan/xslt StylesheetRoot.java

mmidy       01/01/12 13:26:34

  Modified:    java/compat_src/org/apache/xalan/xpath/xml
                        FormatterToDOM.java FormatterToHTML.java
                        FormatterToText.java FormatterToXML.java
                        TreeWalker.java
               java/compat_src/org/apache/xalan/xslt StylesheetRoot.java
  Log:
  Compatibility classes for xalan1 APIs
  
  Revision  Changes    Path
  1.2       +13 -8     xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/FormatterToDOM.java
  
  Index: FormatterToDOM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/FormatterToDOM.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormatterToDOM.java	2001/01/11 19:29:05	1.1
  +++ FormatterToDOM.java	2001/01/12 21:26:08	1.2
  @@ -62,15 +62,17 @@
   //import org.apache.xml.serialize.BaseMarkupSerializer;
   import org.apache.xalan.serialize.DOMSerializer;
   import org.apache.xalan.serialize.SerializerToXML;
  -//import org.apache.xml.serialize.OutputFormat;
  +import org.xml.sax.helpers.ParserAdapter;
  +import org.xml.sax.SAXException;
   
  +
   /**
    * <meta name="usage" content="general"/>
    * This class takes SAX events (in addition to some extra events 
    * that SAX doesn't handle yet) and adds the result to a document 
    * or document fragment.
    */
  -public class FormatterToDOM //extends BaseMarkupSerializer
  +public class FormatterToDOM extends ParserAdapter
   { 
     DOMSerializer m_serializer;
       
  @@ -78,11 +80,12 @@
      * FormatterToDOM instance constructor... it will add the DOM nodes 
      * to the document fragment.
      */
  -  public FormatterToDOM(Document doc, Element elem)
  +  public FormatterToDOM(Document doc, Element elem) throws SAXException
     {
  -    //super(new OutputFormat());
  +    super(new org.apache.xerces.parsers.SAXParser());
       try{
         m_serializer = (new SerializerToXML()).asDOMSerializer();
  +      this.setContentHandler((SerializerToXML)m_serializer);
       }
       catch (java.io.IOException ioe)
       {}
  @@ -92,11 +95,12 @@
      * FormatterToDOM instance constructor... it will add the DOM nodes 
      * to the document fragment.
      */
  -  public FormatterToDOM(Document doc, DocumentFragment docFrag)
  +  public FormatterToDOM(Document doc, DocumentFragment docFrag) throws SAXException
     {
  -    //super(new OutputFormat()); 
  +    super(new org.apache.xerces.parsers.SAXParser()); 
       try{
         m_serializer = (new SerializerToXML()).asDOMSerializer();
  +      this.setContentHandler((SerializerToXML)m_serializer);
       }
       catch (java.io.IOException ioe)
       {}
  @@ -106,11 +110,12 @@
      * FormatterToDOM instance constructor... it will add the DOM nodes 
      * to the document.
      */
  -  public FormatterToDOM(Document doc)
  +  public FormatterToDOM(Document doc) throws SAXException
     {
  -    //super(new OutputFormat());
  +    super(new org.apache.xerces.parsers.SAXParser());
       try{
         m_serializer = (new SerializerToXML()).asDOMSerializer();
  +      this.setContentHandler((SerializerToXML)m_serializer);
       }
       catch (java.io.IOException ioe)
       {}
  
  
  
  1.2       +33 -13    xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/FormatterToHTML.java
  
  Index: FormatterToHTML.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/FormatterToHTML.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormatterToHTML.java	2001/01/11 19:29:06	1.1
  +++ FormatterToHTML.java	2001/01/12 21:26:10	1.2
  @@ -64,6 +64,8 @@
   import org.apache.xalan.serialize.Serializer;
   import org.apache.xalan.serialize.SerializerFactory;
   import org.apache.xalan.serialize.SerializerToHTML;
  +import org.xml.sax.helpers.ParserAdapter;
  +import org.xml.sax.SAXException;
   //import org.apache.xml.serialize.OutputFormat;
   
   /**
  @@ -71,41 +73,59 @@
    * FormatterToHTML formats SAX-style events into XML.
    * Warning: this class will be replaced by the Xerces Serializer classes.
    */
  -public class FormatterToHTML extends SerializerToHTML 
  +public class FormatterToHTML extends ParserAdapter
   { 
  -  public FormatterToHTML()
  -  {  
  -    super();      
  +  
  +  SerializerToHTML m_serializer;
  +  
  +  public FormatterToHTML() throws SAXException 
  +  {
  +    super(new org.apache.xerces.parsers.SAXParser());
  +    m_serializer = new SerializerToHTML();
  +    this.setContentHandler(m_serializer);  
     }
     
     /**
      * Constructor using a writer.
      * @param writer        The character output stream to use.
      */
  -  public FormatterToHTML(Writer writer) 
  +  public FormatterToHTML(Writer writer) throws SAXException  
     {
  -    super ();
  -    this.setWriter(writer);
  +    super(new org.apache.xerces.parsers.SAXParser());
  +    m_serializer = new SerializerToHTML();
  +    m_serializer.setWriter(writer);
  +    this.setContentHandler(m_serializer);    
     }
     
     /**
      * Constructor using an output stream, and a simple OutputFormat.
      * @param writer        The character output stream to use.
      */
  -  public FormatterToHTML(java.io.OutputStream os) 
  -    throws UnsupportedEncodingException
  +  public FormatterToHTML(java.io.OutputStream os)  
  +    throws UnsupportedEncodingException, SAXException 
     {
  -    super ();
  -    this.setOutputStream(os);
  +    super(new org.apache.xerces.parsers.SAXParser());
  +    m_serializer = new SerializerToHTML();
  +    m_serializer.setOutputStream(os);
  +    this.setContentHandler(m_serializer);
  +    
     }
     
     /**
      * Constructor using a writer.
      * @param writer        The character output stream to use.
      */
  -  public FormatterToHTML(FormatterToXML xmlListener) 
  +  public FormatterToHTML(FormatterToXML xmlListener) throws SAXException 
  +  {
  +    super(new org.apache.xerces.parsers.SAXParser());
  +    m_serializer = new SerializerToHTML();
  +    m_serializer.CopyFrom(xmlListener.m_serializer);
  +    this.setContentHandler(m_serializer);
  +  }
  +  
  +  public SerializerToHTML getSerializerObject()
     {
  -    super();
  +    return m_serializer;
     }
     
   }
  
  
  
  1.2       +8 -4      xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/FormatterToText.java
  
  Index: FormatterToText.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/FormatterToText.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormatterToText.java	2001/01/11 19:29:06	1.1
  +++ FormatterToText.java	2001/01/12 21:26:11	1.2
  @@ -61,7 +61,8 @@
   import org.apache.xalan.serialize.Serializer;
   import org.apache.xalan.serialize.SerializerFactory;
   import org.apache.xalan.serialize.SerializerToText;
  -//import org.apache.xml.serialize.OutputFormat;
  +import org.xml.sax.helpers.ParserAdapter;
  +import org.xml.sax.SAXException;
   
   /**
    * <meta name="usage" content="general"/>
  @@ -69,7 +70,7 @@
    * that SAX doesn't handle yet) and produces simple text only.
    * Warning: this class will be replaced by the Xerces Serializer classes.
    */
  -public class FormatterToText //extends TextSerializer
  +public class FormatterToText extends ParserAdapter
   {
     
     private SerializerToText m_serializer;
  @@ -77,9 +78,12 @@
      * FormatterToText instance constructor... it will add the DOM nodes 
      * to the document fragment.
      */
  -  public FormatterToText(Writer pw)
  +  public FormatterToText(Writer pw) throws SAXException
     {
  -    m_serializer = new SerializerToText(); //super();
  +    super(new org.apache.xerces.parsers.SAXParser());
  +    m_serializer = new SerializerToText(); 
  +    m_serializer.setWriter(pw);
  +    this.setContentHandler(m_serializer);
     }
     
     public SerializerToText getSerializerObject()
  
  
  
  1.2       +17 -7     xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/FormatterToXML.java
  
  Index: FormatterToXML.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/FormatterToXML.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormatterToXML.java	2001/01/11 19:29:06	1.1
  +++ FormatterToXML.java	2001/01/12 21:26:13	1.2
  @@ -66,7 +66,8 @@
   import org.apache.xalan.serialize.SerializerToXML;
   //import org.apache.xml.serialize.BaseMarkupSerializer;
   import org.apache.xalan.serialize.Method;
  -//import org.apache.xml.serialize.OutputFormat;
  +import org.xml.sax.helpers.ParserAdapter;
  +import org.xml.sax.SAXException;
   
   
   /**
  @@ -74,12 +75,15 @@
    * FormatterToXML formats SAX-style events into XML.
    * Warning: this class will be replaced by the Xerces Serializer classes.
    */
  -public class FormatterToXML //extends BaseMarkupSerializer 
  +public class FormatterToXML extends ParserAdapter
   {
     SerializerToXML m_serializer;
  -  public void FormatterToXML()
  +  
  +  public FormatterToXML()
     {
  +    super(new org.apache.xerces.parsers.SAXParser());
       m_serializer = new SerializerToXML();
  +    this.setContentHandler(m_serializer);
       //super( new OutputFormat( Method.XML, null, false ) );     
     }
     
  @@ -87,12 +91,14 @@
      * Constructor using a writer.
      * @param writer        The character output stream to use.
      */
  -  public FormatterToXML(Writer writer) 
  +  public FormatterToXML(Writer writer) throws SAXException 
     {
  +    super(new org.apache.xerces.parsers.SAXParser());
       m_serializer = new SerializerToXML();
      // super( format != null ? format : new OutputFormat( Method.XML, null, false ) );
       //_format.setMethod( Method.XML );
       m_serializer.setWriter( writer );
  +    this.setContentHandler(m_serializer);
     }
     
     /**
  @@ -100,23 +106,27 @@
      * @param writer        The character output stream to use.
      */
     public FormatterToXML(java.io.OutputStream os) 
  -    throws UnsupportedEncodingException
  +    throws UnsupportedEncodingException , SAXException 
     {
  +    super(new org.apache.xerces.parsers.SAXParser());
       m_serializer = new SerializerToXML();
       //super( format != null ? format : new OutputFormat( Method.XML, null, false ) );
       //_format.setMethod( Method.XML );
       m_serializer.setOutputStream( os );
  +    this.setContentHandler(m_serializer);
     }
     
     /**
      * Constructor using a writer.
      * @param writer        The character output stream to use.
      */
  -  public FormatterToXML(FormatterToXML xmlListener) 
  +  public FormatterToXML(FormatterToXML xmlListener) throws SAXException 
     {
  +    super(new org.apache.xerces.parsers.SAXParser());
       m_serializer = new SerializerToXML();
       m_serializer.CopyFrom(xmlListener.m_serializer);
  -    //super( new OutputFormat( Method.XML, null, false ) );  
  +    //super( new OutputFormat( Method.XML, null, false ) );
  +    this.setContentHandler(m_serializer);
     }
     
     public SerializerToXML getSerializerObject()
  
  
  
  1.2       +25 -3     xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/TreeWalker.java
  
  Index: TreeWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/TreeWalker.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TreeWalker.java	2001/01/11 19:29:06	1.1
  +++ TreeWalker.java	2001/01/12 21:26:15	1.2
  @@ -67,17 +67,39 @@
    * This class does a pre-order walk of the DOM tree, calling the FormatterListener
    * interface as it goes.
    */
  -public class TreeWalker extends org.apache.xml.utils.TreeWalker
  +public class TreeWalker //extends org.apache.xml.utils.TreeWalker
   {
  +  
  +  org.apache.xml.utils.TreeWalker m_walker; 
  +  
     /**
      * Constructor.
      * @param   formatterListener The implemention of the 
      * FormatterListener operation (toXMLString, digest, ...)
      */
  -  public TreeWalker(ContentHandler formatterListener) 
  +  public TreeWalker(DocumentHandler formatterListener) 
     {
  -    super(formatterListener);
  +    if(formatterListener instanceof FormatterToXML)
  +      m_walker = new org.apache.xml.utils.TreeWalker(((FormatterToXML)formatterListener).getSerializerObject());
  +    //super(formatterListener);
     } 
    
  +  /**
  +   * Perform a pre-order traversal non-recursive style.
  +   */
  +  public void traverse(Node pos) throws SAXException 
  +  {
  +    m_walker.traverse(pos);
  +  }
  +  
  +  /**
  +   * Perform a pre-order traversal non-recursive style.
  +   */
  +  public void traverse(Node pos, Node top) throws SAXException 
  +  {
  +    m_walker.traverse(pos, top);
  +  }
  +  
  +  
     
   }  //TreeWalker
  
  
  
  1.3       +7 -7      xml-xalan/java/compat_src/org/apache/xalan/xslt/StylesheetRoot.java
  
  Index: StylesheetRoot.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xslt/StylesheetRoot.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StylesheetRoot.java	2001/01/11 21:43:55	1.2
  +++ StylesheetRoot.java	2001/01/12 21:26:29	1.3
  @@ -361,7 +361,7 @@
      * @return A compatible SAX serializer
      */
     public DocumentHandler makeSAXSerializer( Writer writer, OutputFormat format )
  -    throws IOException
  +    throws IOException, SAXException 
     {
       DocumentHandler handler;
       if ( format == null )
  @@ -377,8 +377,8 @@
         if ( format.getMethod().equalsIgnoreCase( "html" ) )
         {
           FormatterToHTML serializer = new FormatterToHTML(writer);
  -        serializer.setOutputFormat(props.getProperties());
  -        ((ParserAdapter)handler).setContentHandler(serializer);
  +        serializer.getSerializerObject().setOutputFormat(props.getProperties());
  +        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
         }
         else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
         {
  @@ -418,7 +418,7 @@
      * @return A compatible SAX serializer
      */
     public DocumentHandler makeSAXSerializer( OutputStream ostream, OutputFormat format )
  -    throws UnsupportedEncodingException, IOException
  +    throws UnsupportedEncodingException, IOException, SAXException
     {
       DocumentHandler handler;
       OutputProperties props;
  @@ -435,8 +435,8 @@
         if ( format.getMethod().equalsIgnoreCase( "html" ) )
         {
           FormatterToHTML serializer = new FormatterToHTML(ostream);
  -        serializer.setOutputFormat(props.getProperties());
  -        ((ParserAdapter)handler).setContentHandler(serializer);
  +        serializer.getSerializerObject().setOutputFormat(props.getProperties());
  +        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
         }
         else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
         {
  @@ -503,7 +503,7 @@
      * @return A compatible SAX serializer
      */
     public DocumentHandler getSAXSerializer( OutputStream ostream )
  -    throws UnsupportedEncodingException, IOException
  +    throws UnsupportedEncodingException, IOException, SAXException
     {
      return makeSAXSerializer(ostream, getOutputFormat());
     }