You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Cory Isaacson (Compuflex)" <ci...@compuflex.com> on 2000/07/27 20:05:37 UTC

Re:

Cameron,

Are you using servlets for the transformation and to return the data? If so,
I wrote one which returns a raw XML document (not HTML) and returns it to an
Applet on the client, and then the Applet displays it. However, the entire
document was returned without problem, and it should be the same as what you
are doing.

Here is a code snippet from my test example:

Servlet Code:

      response.setContentType("text/xml");
      OutputFormat outputFormat = new OutputFormat(xmlDoc);
      XMLSerializer serializer = new XMLSerializer(response.getWriter(),
outputFormat);
      serializer.serialize(xmlDoc);
      serializer.flush();

Client (Applet) Code:

      /* Create the URL.*/
      URL url = new URL("http://localhost/...[ServletName]");

      /* Open the URL.*/
      URLConnection urlConn = url.openConnection();

      urlConn.setUseCaches(false);
      urlConn.setRequestProperty("CONTENT_TYPE", "text/xml");
      urlConn.setDoInput(true);
      urlConn.setDoOutput(true);

      /* Read the response.*/
      BufferedInputStream inputStream = new
BufferedInputStream(urlConn.getInputStream());

      int charValue = 0;
      byte xmlBuffer[] = null;
      StringBuffer xmlString = new StringBuffer();
      String tempString = null;

      /* Read all available bytes in a single chunk.*/
      while((charValue = inputStream.read()) != -1)
      {
        xmlString.append(String.valueOf((char)charValue));
      }//while((charValue = inputStream.read()) != -1)

      /* Parse the xml document.*/
      xmlResult = xmlString.toString();
      InputSource xmlInput = new InputSource(new StringReader(xmlResult));
      DOMParser parser = new DOMParser();
      parser.parse(xmlInput);
      sqlDoc = parser.getDocument();

The browser should do the same thing by itself as well.

Hope that helps. You should copy the xalan group on stuff like this as well.

Cory


----- Original Message -----
From: "Cameron Biggelaar" <ca...@vanzyl.com.au>
To: <ci...@compuflex.com>
Sent: Thursday, July 27, 2000 12:31 AM


> Hi Cory,
>
>   haven been going through the xalan mailing list and have a problem I
> think is similar to one that you had along your travels.
>
> Basically I'm trying to output a DOM which is the result of a Sucessful
XSL
> transform -> HTML.  However when trying to write the DOM to the browser
I'm
> having all sorts of problems.  I have tried many approaches and none of
> them working to my complete satisfaction.  I am currently viewing the Data
> from IE 5 on Win2K.
>
> The current approach:
>
>      FormatterToHTML fl = new FormatterToHTML(out);
>      TreeWalker tw = new TreeWalker(fl);
>      tw.traverse(doc);
>
> with an out.flush() and out.close() a little later down the track.
>
> Where out is an output stream.  I have also tried using the serializer
> method and both seem to suffer from problems flushing the data to the
> client.  The first instance with the server and client on the local
machine
> I get an incomplete document sent to the client intermittently, but more
> regularly with larger DOM's. The second instance is where the client is on
> a separate machine than the server ( I have tested this on several LAN's)
> and sometimes the server sends no data back to the client.  I have not
> snooped the network in the later case to see what's happening.
>
> Anyhow I'm using xalan 1.0.1 and xerces 1.0.3, and have tried versions
> xalan 1.1 and xerces 1.1.2 with no success.
>
> Any suggestions?
>
> Thanks in advance.
> Cameron
>


Re:

Posted by Cameron Biggelaar <ca...@vanzyl.com.au>.
Thanks I have solved the problem.

I was using the JSDK2.1 and JDK 1.2.2_006 on Win2K and there is an obscure 
bug that sends TCP reset headers under particular circumstances following a 
POST.  The client receives all the data immediately followed by 5 TCP reset 
commands! hence the client html page is only partially populated.

Thanks Cam.

At 02:05 PM 27/07/2000 -0400, Cory Isaacson \(Compuflex\) wrote:
>Cameron,
>
>Are you using servlets for the transformation and to return the data? If so,
>I wrote one which returns a raw XML document (not HTML) and returns it to an
>Applet on the client, and then the Applet displays it. However, the entire
>document was returned without problem, and it should be the same as what you
>are doing.
>
>Here is a code snippet from my test example:
>
>Servlet Code:
>
>       response.setContentType("text/xml");
>       OutputFormat outputFormat = new OutputFormat(xmlDoc);
>       XMLSerializer serializer = new XMLSerializer(response.getWriter(),
>outputFormat);
>       serializer.serialize(xmlDoc);
>       serializer.flush();
>
>Client (Applet) Code:
>
>       /* Create the URL.*/
>       URL url = new URL("http://localhost/...[ServletName]");
>
>       /* Open the URL.*/
>       URLConnection urlConn = url.openConnection();
>
>       urlConn.setUseCaches(false);
>       urlConn.setRequestProperty("CONTENT_TYPE", "text/xml");
>       urlConn.setDoInput(true);
>       urlConn.setDoOutput(true);
>
>       /* Read the response.*/
>       BufferedInputStream inputStream = new
>BufferedInputStream(urlConn.getInputStream());
>
>       int charValue = 0;
>       byte xmlBuffer[] = null;
>       StringBuffer xmlString = new StringBuffer();
>       String tempString = null;
>
>       /* Read all available bytes in a single chunk.*/
>       while((charValue = inputStream.read()) != -1)
>       {
>         xmlString.append(String.valueOf((char)charValue));
>       }//while((charValue = inputStream.read()) != -1)
>
>       /* Parse the xml document.*/
>       xmlResult = xmlString.toString();
>       InputSource xmlInput = new InputSource(new StringReader(xmlResult));
>       DOMParser parser = new DOMParser();
>       parser.parse(xmlInput);
>       sqlDoc = parser.getDocument();
>
>The browser should do the same thing by itself as well.
>
>Hope that helps. You should copy the xalan group on stuff like this as well.
>
>Cory
>
>
>----- Original Message -----
>From: "Cameron Biggelaar" <ca...@vanzyl.com.au>
>To: <ci...@compuflex.com>
>Sent: Thursday, July 27, 2000 12:31 AM
>
>
> > Hi Cory,
> >
> >   haven been going through the xalan mailing list and have a problem I
> > think is similar to one that you had along your travels.
> >
> > Basically I'm trying to output a DOM which is the result of a Sucessful
>XSL
> > transform -> HTML.  However when trying to write the DOM to the browser
>I'm
> > having all sorts of problems.  I have tried many approaches and none of
> > them working to my complete satisfaction.  I am currently viewing the Data
> > from IE 5 on Win2K.
> >
> > The current approach:
> >
> >      FormatterToHTML fl = new FormatterToHTML(out);
> >      TreeWalker tw = new TreeWalker(fl);
> >      tw.traverse(doc);
> >
> > with an out.flush() and out.close() a little later down the track.
> >
> > Where out is an output stream.  I have also tried using the serializer
> > method and both seem to suffer from problems flushing the data to the
> > client.  The first instance with the server and client on the local
>machine
> > I get an incomplete document sent to the client intermittently, but more
> > regularly with larger DOM's. The second instance is where the client is on
> > a separate machine than the server ( I have tested this on several LAN's)
> > and sometimes the server sends no data back to the client.  I have not
> > snooped the network in the later case to see what's happening.
> >
> > Anyhow I'm using xalan 1.0.1 and xerces 1.0.3, and have tried versions
> > xalan 1.1 and xerces 1.1.2 with no success.
> >
> > Any suggestions?
> >
> > Thanks in advance.
> > Cameron
> >