stephan     2003/03/07 05:19:09

  Modified:    src/java/org/apache/cocoon/xml/dom DOMStreamer.java
  Log:
  Solved problem with a NoSuchMethodError, see
  http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=104694413702863&w=2
  Not such elegant as before, but it works.
  
  Revision  Changes    Path
  1.10      +40 -8     xml-cocoon2/src/java/org/apache/cocoon/xml/dom/DOMStreamer.java
  
  Index: DOMStreamer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/xml/dom/DOMStreamer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DOMStreamer.java  28 Feb 2003 00:23:13 -0000      1.9
  +++ DOMStreamer.java  7 Mar 2003 13:19:09 -0000       1.10
  @@ -52,6 +52,7 @@
   
   import org.apache.cocoon.xml.AbstractXMLProducer;
   import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.cocoon.xml.XMLProducer;
   import org.apache.cocoon.xml.EmbeddedXMLPipe;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
  @@ -87,7 +88,7 @@
    *         (Apache Software Foundation)
    * @version CVS $Id$
    */
  -public class DOMStreamer extends AbstractXMLProducer {
  +public class DOMStreamer implements XMLProducer {
   
       /** Indicates whether namespace normalization should happen. */
       protected boolean normalizeNamespacesOn = true;
  @@ -121,7 +122,8 @@
       public DOMStreamer(ContentHandler content) {
           this(content, null);
           if (content instanceof LexicalHandler) {
  -            setLexicalHandler((LexicalHandler) content);
  +            defaultDOMStreamer.setLexicalHandler((LexicalHandler) content);
  +            namespaceNormalizingDOMStreamer.setLexicalHandler((LexicalHandler) 
content);
           }
       }
   
  @@ -130,11 +132,40 @@
        */
       public DOMStreamer(ContentHandler content, LexicalHandler lexical) {
           this();
  -        setContentHandler(content);
  -        setLexicalHandler(lexical);
  +        defaultDOMStreamer.setContentHandler(content);
  +        defaultDOMStreamer.setLexicalHandler(lexical);
  +        namespaceNormalizingDOMStreamer.setContentHandler(content);
  +        namespaceNormalizingDOMStreamer.setLexicalHandler(lexical);
       }
   
       /**
  +     * Set the <code>XMLConsumer</code> that will receive XML data.
  +     */
  +    public void setConsumer(XMLConsumer consumer) {
  +        defaultDOMStreamer.setContentHandler(consumer);
  +        defaultDOMStreamer.setLexicalHandler(consumer);
  +        namespaceNormalizingDOMStreamer.setContentHandler(consumer);
  +        namespaceNormalizingDOMStreamer.setLexicalHandler(consumer);
  +    }
  +
  +    /**
  +     * Set the <code>LexicalHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  +     * accessing the protected <code>super.lexicalHandler</code> field.
  +     *
  +     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  +     *                                  the <code>XMLConsumer</code> were
  +     *                                  already set.
  +     */
  +    public void setLexicalHandler(LexicalHandler handler) {
  +        // FIXME Shouldn't be used IHMO.
  +
  +        defaultDOMStreamer.setLexicalHandler(handler);
  +        namespaceNormalizingDOMStreamer.setLexicalHandler(handler);
  +    } 
  +
  +    /**
        * Start the production of SAX events.
        */
       public void stream(Node node) throws SAXException {
  @@ -153,7 +184,7 @@
       }
   
       public void recycle() {
  -        super.recycle();
  +        defaultDOMStreamer.recycle();
           namespaceNormalizingDOMStreamer.recycle();
           normalizeNamespacesOn = true;
       }
  @@ -182,7 +213,7 @@
        * @author Bruno Dumon (bruno at outerthought dot org)
        * @author Xalan team
        */
  -    public class NamespaceNormalizingDOMStreamer {
  +    public class NamespaceNormalizingDOMStreamer extends AbstractXMLProducer {
           /**
            * Information about the current element. Used to remember the localName, 
qName
            * and namespaceURI for generating the endElement event, and holds the 
namespaces
  @@ -196,6 +227,7 @@
           protected int newPrefixCounter = 0;
   
           public void recycle() {
  +            super.recycle();
               currentElementInfo = null;
               newPrefixCounter = 0;
           }
  @@ -580,7 +612,7 @@
        * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
        *         (Apache Software Foundation)
        */
  -    public class DefaultDOMStreamer {
  +    public class DefaultDOMStreamer extends AbstractXMLProducer {
   
           /** The private transformer for this instance */
           protected Transformer transformer;
  
  
  

Reply via email to