TXDocument doc = null;
Document doc = null;
  private void processContainerSAX(XMLObjectProvider myObjectProvider,                                   BContentHandler myContentHandler, SAXParser mySaxParser, OutputStream out,                                   final String collectionType){       try{           TXDocument doc = null;           synchronized( myObjectProvider) {                     Object odoc= getDocument(myObjectProvider);                     if( odoc instanceof TXDocument) doc = (TXDocument)odoc;           }           if( ( doc != null) )           {                    StringWriter sw = new StringWriter();                    try{                        doc.print(sw);                    } catch( IOException ex ) {                        ex.printStackTrace();                    }                    StringBuffer sb = sw.getBuffer();                    StringReader str_reader = new StringReader(sb.toString() );                    try {                        InputSource in = new InputSource(str_reader);                        mySaxParser.parse(in);                    } catch (IOException e) {                        System.err.println("I/O exception reading XML document. " + e);                        e.printStackTrace();                    } catch (SAXException e) {                        System.err.println("SAX exception parsing document. " + e);                        e.printStackTrace();                    }                   //-----------------------------------------------------------------                   // Traverse and "write" the tree                   // Start from the root object                   //-----------------------------------------------------------------                   PrintWriter pw = new PrintWriter(out);                   pw.println("<?xml version=\"1.0\"?>");                   Iterator it3 = myContentHandler.getRootElements().iterator();                   while(it3.hasNext()){                      BElement be = (BElement)it3.next();                      be.print(pw);                   }                   pw.flush();                   System.out.println("[GenericQueryXML] pw.toString()=" + pw.toString() );            }       } catch (Exception ex ){            ex.printStackTrace();       }  }