XT (XSLServlet) ignores media-type for xml?

Subject: XT (XSLServlet) ignores media-type for xml?
From: Tom Myers <tom.myers@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 07 Mar 2000 10:21:59 -0500
I think I'm probably missing something obvious.

I'm trying to use jclark's XSLServlet class to generate
output which may be xhtml or wml, and I need to set the
content-type accordingly; well, "text/html" is okay in
one case, but I need "text/vnd.wap.wml" (or preferably
"text/vnd.wap.wml;charset=ISO-8859-1") in the other. I
seem to have a choice between getting the content-type
right, and getting the actual content right: I can do
either, but not both.

Specifically, I can generate exactly the right output 
headers with

   <xsl:output method="xml" media-type=...

but my browser (IE4) simply offers to save the file;
the media-type is being ignored. I can get the content-type 
set to the media-type via

   <xsl:output method="html" media-type=....

and all is well, except that the header is always
"<html..." where I need to set it, e.g. to "<wml..."
(and yes, I do need to include the XML headers).

Looking at the source code, I see that the contentType
is set within ServletDestination.getOutputStream, and that
the XMLOutputHandler class says merely

  this.out = dest.getOutputStream("application/xml", null);

where the HTMLOutputHandler class contains

  String mediaType = atts.getValue("media-type");
and then calls on
  writer = dest.getWriter(mediaType, encoding);

Destination.java lays out both getOutputStream and getWriter,
but I am not clear on the relationships here. I've tried
making an editted XMLOutputHandler class and calling it by

 method="http://www.jclark.com/xt/java/MyNa.jspUtil.XMLOutputHandler";

because it looks from the code in OutputMethodHandlerImpl.java
as if that's the way to do it, but it's not being called; it
gets a no-such-prefix error unless I define xmlns:http="..something,
and maybe I'm just defining it to be the wrong something. 

I admit I'm feeling really stupid, and I probably deserve it...I'm
now using jsp pages to set up a bean in a session with an arbitrary
list of named sql.PreparedStatement strings, save the session
into a session cache, forward to my version of XSLServlet which just
adds one line to define the session ID as a parameter so that an
extension function can look up the session in its cache, pull out
and activate the bean, extract a nodeiterator representing the
results to an arbtrary database query or update, and format...
and the output is fine. I just can't see it in the browser because
I can't set the content-type.  aarrrrggh.

Tom Myers



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread