xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruce McDougald" <bmcdoug...@hotmail.com>
Subject SAX Filter Output in Servlet
Date Mon, 07 Oct 2002 22:54:33 GMT
I am having a problem sending html output as an http response from my SAX
transform.  I'm getting output to the system console when I use System.out
for my OutputStream, but thats no good for what I need.  From the XALAN
documentation, I'm supposed to
create a PrintWriter object, but that is not compatable to the Serializer
object created in my SAX transformation code.

Can anyone tell me how to redirect the HTML output created from the
serializer object back to the servlet?

Thanks.

Bruce

-----------------------------------------------------------------------
Here's my code:
-----------------------------------------------------------------------
 ...
      PrintWriter out = servletresponse.getWriter();

      XMLReader reader = XMLReaderFactory.createXMLReader();

      SAXTransformerFactory saxTFactory = ((SAXTransformerFactory)
tFactory);

      XMLFilter xmlFilter1 = new SAXParse();

      xmlFilter1.setParent(reader);

      XMLFilter xmlFilter2 =
               saxTFactory.newXMLFilter(new
StreamSource("http://localhost/taymac.nsf/dynitmact.xsl"));

      xmlFilter2.setParent(xmlFilter1);

      // xmlFilter2 outputs SAX events to the serializer.
      Serializer serializer = SerializerFactory.getSerializer

(OutputProperties.getDefaultMethodProperties("html"));

      serializer.setOutputStream(out);    // <--- System.out was here in the
example, but I need output to go back as servlet response!!!!!!

      xmlFilter2.setContentHandler(serializer.asContentHandler());

      xmlFilter2.parse(new
InputSource("d:\\notes\\data\\domino\\cgi-bin\\itmact.xml"));
...

Mime
View raw message