[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Any samples of client-side XSLT to generate webpages?


Subject: RE: [xsl] Any samples of client-side XSLT to generate webpages?
From: "Daniel Joshua" <daniel.joshua@xxxxxxxxxxxx>
Date: Tue, 27 Jul 2004 23:14:39 +0800

Yes. That is what I am trying to do. I even posted the code I used to do it
in an earlier email on the list in hope someone could spot my mistake.


Repeat:

Can anyone explain to me why the below happens:

(1) http://202.156.224.29:18080/shatteredspace/login.do
  - works in IE
  - unable to submit form in Mozilla

(2) http://202.156.224.29:18080/shatteredspace/login.do?transform=true
  - works in Mozilla - currently need to manually add the '?transform=true',
but I might automate this later
  - nothing visible (except background graphic) in IE


Here's the code that either (1) writes out XML with a XSLT stylesheet or
(2) uses saxon to transform into HTML.

  protected void writeDocument()
  {
    try
    {
      boolean transform =
ConversionUtils.primitiveBooleanValue(_request.getParameter(PARAM_TRANSFORM)
);
      if(transform)
      {
        InputStream inputStream =
_request.getSession().getServletContext().getResourceAsStream("stylesheets/"
+ _stylesheet);

        //_response.setContentType("'application/xhtml+xml"); // currently
most browsers do not support this yet
        _response.setContentType("text/html");

        //TODO: Add Caching
        TransformerFactory transformerFactory =
TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer(new
StreamSource(inputStream));
        transformer.transform(new JDOMSource(_document), new
StreamResult(_response.getOutputStream()));
      }
      else
      {
        _document.addContent(0, new ProcessingInstruction("xml-stylesheet",
"type=\"text/xsl\" href=\"stylesheets/" + _stylesheet + "\""));

        _response.setContentType("text/xml");

        XMLOutputter xmlOutputter = new
XMLOutputter(Format.getPrettyFormat());
        xmlOutputter.output(_document, _response.getWriter());
      }
    }
    catch(Exception ex)
    {
      throw new NestableRuntimeException("Failed to write document", ex);
    }
  }


> Make sure your server or servlet/whatever is configured to send the
> right MIME type to the browser...

I believe I am using the right mime type, correct me if I am wrong. :p


Regards,
Daniel


-----Original Message-----
From: Emmanouil Batsis [mailto:Emmanouil.Batsis@xxxxxxxxxxx]
Sent: Tuesday, 27 July, 2004 10:19 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Any samples of client-side XSLT to generate webpages?


Daniel Joshua wrote:

>Ok, I understand this now.
>
>If I ever need to produce HTML fragments I will use Sarissa (I find how it
>works very intersting). But the approach I am currently trying is to
produce
>whole HTML pages by XSLT transformation in the client's browser.
>

Why dont you just send XML with an stylesheet PI to the  browser then?
Make sure your server or servlet/whatever is configured to send the
right MIME type to the browser...

hth,

Manos


Current Thread
Keywords