• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with XSL Tranformation in Servlet

 
Pete Neu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I need to generate some HTML from an XSL Tranformation. XML is generated on the fly. The XSL File is static. My code looks like this.

PrintWriter out = response.getWriter();
StreamResult streamResult = new StreamResult(out);

SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
File xsltFile = new File(getServletContext().getRealPath("/xml/html.xsl"));
Source xsltSrc = new StreamSource(xsltFile);
Templates templates = saxTransformerFactory.newTemplates(xsltSrc);
TransformerHandler handler = saxTransformerFactory.newTransformerHandler(templates);

// custom xml generator nothing special
// just: handler.startElement ...
XmlTransformer xmlt = new XmlTransformer();
xmlt.generateXML(handler,gr,av,dataList);

SAXResult result = new SAXResult(handler);
handler.setResult(result);

I only get null as error message. I can't figure out what's wrong. XML Generator works ok for normal xml output. Can anyone help?

cheers,
Pete
 
Pete Neu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just did some addional debugging and discovered that the java runtime exception occurs when the handler.endDocument() method is called. Does anyone know what this means?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic