xsl-list
[Top] [All Lists]

Re: media-type setting in Java HttpServletResponse

2006-01-06 01:47:15
Perhaps:

res.setContentType(trans.getOutputProperties().getProperty("media-type"));

Cheers,
Geert

Ai / Hiro wrote:
Hi list,

I'm using java servlet and XSLT 2.0 with Saxon-B 8.6.1 and want to 
output the result of a transformation with a proper content type/media 
type, using the @media-type attribute of an <xsl:output/> element or 
<xsl:result-document/> element that has the attribute or the @format 
attribute that refers to a named <xsl:output/> element. However, the 
specified media-type is not recognized this way, so, I have to use 
HttpServletResponse.setContentType(), which needs to be used before the 
transformation. Other attributes of xsl:output, such as @encoding, work 
well, but @media-type does not, at least with the following codes:

  public void doGet(HttpServletRequest req, HttpServletResponse res) 
throws IOException {
    ...
    //PrintWriter out = res.getWriter(); // does not work
    OutputStream out = res.getOutputStream(); // neither
    try {
      trans.transform(xmlSource, new StreamResult(out));
    }
    ...
  }

Does anyone have a clue how to make this work?

Regards,
-- 
Ai

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>