if( odoc instanceof TXDocument) doc = (TXDocument)odoc;
if( odoc instanceof Document) doc = (Document)odoc;
  private void processContainerXSL(XMLObjectProvider myObjectProvider,                                   XSLTInputSource  myXSL, OutputStream out,                                   final String collectionType )  {       TXDocument doc = null;       try{             synchronized( myObjectProvider)             {                     Object odoc= getDocument(myObjectProvider);                     if( odoc instanceof TXDocument) doc = (TXDocument)odoc;                     if( doc != null)                     {                         //Element ce = doc.createElement("Container");                         //ce.setAttribute("Event", "ADD");                         //doc.getFirstChild().appendChild(ce);                         NodeList children = doc.getFirstChild().getChildNodes();                         for(int i=0; i<children.getLength(); i++)                         {                             Node n= (Node)children.item(i);                             Element elem = doc.createElement("Subscription");                             if( collectionType.equals(GenericLogic.collectionType_ADD)) {                                 elem.setAttribute("Event","ADD");                             }                             else if( collectionType.equals(GenericLogic.collectionType_CHANGE)){                                 elem.setAttribute("Event","CHANGE");                             }                             else if( collectionType.equals(GenericLogic.collectionType_REMOVE)){                                 elem.setAttribute("Event","REMOVE");                             } else                                 elem.setAttribute("Event","UNKNOWN");                             n.appendChild(elem);                         }                     }             }             //             // This is BAD.             // TODO:  FIX THIS             // converting TO STRING TO APPLY XSL is v. inefficient.             // When COUGAAR XML parser version is updated, will go away.             //             if( (myXSL != null) && ( doc != null) )             {                    StringWriter sw = new StringWriter();                    doc.print(sw);                    StringBuffer sb = sw.getBuffer();                    //System.err.println("returnVal, sb.toSTring()=" + sb.toString().substring(0,120));                    //System.err.println("returnVal, sbuf.toString()=" + sbuf.toString());                    StringReader sr = new StringReader(sb.toString() );                    applyXSL(sr,myXSL, out);                    // DEBUG                    //doc.print(new PrintWriter(System.out));                    //             } else if( (doc != null)  )                           doc.print(new PrintWriter(out));       } catch (Exception ex ) {           ex.printStackTrace();       }  }