cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/source SourceUtil.java
Date Wed, 09 Oct 2002 07:18:57 GMT
cziegeler    2002/10/09 00:18:57

  Modified:    src/java/org/apache/cocoon/components/source SourceUtil.java
  Log:
  Workaround for serializing xml
  
  Revision  Changes    Path
  1.9       +62 -51    xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceUtil.java
  
  Index: SourceUtil.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceUtil.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SourceUtil.java	8 Oct 2002 14:43:20 -0000	1.8
  +++ SourceUtil.java	9 Oct 2002 07:18:57 -0000	1.9
  @@ -60,6 +60,7 @@
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.serialization.Serializer;
   import org.apache.cocoon.xml.IncludeXMLConsumer;
  +import org.apache.cocoon.xml.XMLUtils;
   import org.apache.cocoon.xml.dom.DOMBuilder;
   import org.apache.cocoon.xml.dom.DOMStreamer;
   import org.apache.excalibur.source.Source;
  @@ -312,58 +313,68 @@
                       streamer.stream(frag);
                   } else {
                       // Lookup the Serializer
  -                    ComponentSelector selector = null;
  -                    Serializer serializer = null;
  -                    OutputStream oStream = null;
  -                    try {
  -                        selector = (ComponentSelector)manager.lookup(Serializer.ROLE +
"Selector");
  -                        System.out.println("Selector: " + selector + " - " + serializerName);
  -                        serializer = (Serializer)selector.select(serializerName);
  -                        oStream = ws.getOutputStream();
  -                        serializer.setOutputStream(oStream);
  -                        DOMStreamer streamer = new DOMStreamer(serializer);
  -                        streamer.stream(frag);
  -                    } finally {
  -                        if (oStream != null) {
  -                            oStream.flush();
  -                            try {
  -                                oStream.close();
  -                            } finally {
  -                                if ( selector != null ) {
  -                                    selector.release( serializer );
  -                                    manager.release( selector );
  -                                }
  -                            }
  -                        }
  -                    }
  +                // FIXME (CZ) : Due to the CM hierarchy we don't get the
  +                // correct serializer selector...
  +//                    ComponentSelector selector = null;
  +//                    Serializer serializer = null;
  +//                    OutputStream oStream = null;
  +//                    try {
  +//                        selector = (ComponentSelector)manager.lookup(Serializer.ROLE
+ "Selector");
  +//                        serializer = (Serializer)selector.select(serializerName);
  +//                        oStream = ws.getOutputStream();
  +//                        serializer.setOutputStream(oStream);
  +//                        DOMStreamer streamer = new DOMStreamer(serializer);
  +//                        streamer.stream(frag);
  +//                    } finally {
  +//                        if (oStream != null) {
  +//                            oStream.flush();
  +//                            try {
  +//                                oStream.close();
  +//                            } finally {
  +//                                if ( selector != null ) {
  +//                                    selector.release( serializer );
  +//                                    manager.release( selector );
  +//                                }
  +//                            }
  +//                        }
  +//                    }
  +                    final String content = XMLUtils.serializeNode(frag, 
  +                                                                   XMLUtils.defaultSerializeToXMLFormat(false));
  +                    OutputStream oStream = ws.getOutputStream();
  +                    oStream.write(content.getBytes());
  +                    oStream.flush();
  +                    oStream.close();
                   }
               } else {
                   // and now serializing...
                   // Lookup the Serializer
  -                ComponentSelector selector = null;
  -                Serializer serializer = null;
  -                ByteArrayOutputStream oStream = new ByteArrayOutputStream();
  -                try {
  -                    selector = (ComponentSelector)manager.lookup(Serializer.ROLE + "Selector");
  -                    System.out.println("Selector: " + selector + " - " + serializerName);
  -                    serializer = (Serializer)selector.select(serializerName);
  -                    serializer.setOutputStream(oStream);
  -                    DOMStreamer streamer = new DOMStreamer(serializer);
  -                    streamer.stream(frag);
  -                } finally {
  -                    if (oStream != null) {
  -                        oStream.flush();
  -                        try {
  -                            oStream.close();
  -                        } finally {
  -                            if ( selector != null ) {
  -                                selector.release( serializer );
  -                                manager.release( selector );
  -                            }
  -                        }
  -                    }
  -                }
  -                final String content = oStream.toString();
  +                // FIXME (CZ) : Due to the CM hierarchy we don't get the
  +                // correct serializer selector...
  +//                ComponentSelector selector = null;
  +//                Serializer serializer = null;
  +//                ByteArrayOutputStream oStream = new ByteArrayOutputStream();
  +//                try {
  +//                    selector = (ComponentSelector)manager.lookup(Serializer.ROLE + "Selector");
  +//                    serializer = (Serializer)selector.select(serializerName);
  +//                    serializer.setOutputStream(oStream);
  +//                    DOMStreamer streamer = new DOMStreamer(serializer);
  +//                    streamer.stream(frag);
  +//                } finally {
  +//                    if (oStream != null) {
  +//                        oStream.flush();
  +//                        try {
  +//                            oStream.close();
  +//                        } finally {
  +//                            if ( selector != null ) {
  +//                                selector.release( serializer );
  +//                                manager.release( selector );
  +//                            }
  +//                        }
  +//                    }
  +//                }
  +//                final String content = oStream.toString();
  +                final String content = XMLUtils.serializeNode(frag, 
  +                                                               XMLUtils.defaultSerializeToXMLFormat(false));
                   resolver.release(source);
                   if (parameters == null) {
                       parameters = new SourceParameters();
  @@ -381,8 +392,8 @@
               throw new ProcessingException(ce);
           } catch (SAXException ce) {
               throw new ProcessingException(ce);
  -        } catch (ComponentException ce) {
  -            throw new ProcessingException("Exception during lookup of component.", ce);
  +//        } catch (ComponentException ce) {
  +//            throw new ProcessingException("Exception during lookup of component.", ce);
           } catch (SourceException se) {
               throw SourceUtil.handle(se);
           } finally {
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message