You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Mathias Schulze <MS...@web.de> on 2001/03/16 10:24:02 UTC

Problem- Strings to HTML

Hi all,

I have a problem, transforming two Strings(XML and XSL) to a HTML-String.
As I'm using my own XML and XSL String, I get an NullPointerExc. !
So I tryed the sample Files and the same Exception happens.

I have my own method 'contakt(URL)', that reads the Data from the URL and returns a string. That works well, because the XML comes from StoredProcedure and the XSL comes from a file, both from the Server.

Using 'System.out.println(contakt(XSLDATA));' shows a XSL-String!

Now a part of my listing:

synchronized (m_tfactory){
  StringReader sr = null;
  String string1, string2;
  StreamSource st = null;
  Templates tm = null;
  Templates templates=null;
  try{
       sr = new StringReader(contakt(XSLDATA));
     }
     catch (Exception e){System.out.println("error 1 " + e);}
  try{ 
       st = new StreamSource(sr);	
     }
     catch (Exception e){ System.out.println("error 2 " + e); }
     string2=st.toString();
  try{
       templates = m_tfactory.newTemplates(st); 
     }
     catch (Exception e){ System.out.println("error 3 " + e); }
// next line does the same, but isn't as easy to debug as the lines before
//Templates templates = m_tfactory.newTemplates(new StreamSource(new StringReader(contakt(XSLDATA))));
 Transformer transformer = templates.newTransformer();
 transformer.transform(new StreamSource(new StringReader(contakt(XMLDATA))), new StreamResult(pw)); //(new StreamSource(xmlbuf), new StreamResult(pw));
}
      System.out.println("Primed the pump!");
      this.showStatus("Ready to go!");
    }
    catch (Exception e)
    {
      this.showStatus("Could not prime the pump!");
      System.out.println("Could not prime the pump!");
      e.printStackTrace();
    }

The null Pointer exception happens at 'error 2' position.
Please write back.

Mathias


______________________________________________________________________________
Die Fachpresse ist sich einig: WEB.DE 20mal Testsieger! Kostenlos E-Mail, 
Fax, SMS, Verschlüsselung, POP3, WAP....testen Sie uns! http://freemail.web.de