Subject: RE: [xsl] Any samples of client-side XSLT to generate webpages? From: "Daniel Joshua" <daniel.joshua@xxxxxxxxxxxx> Date: Tue, 27 Jul 2004 23:36:22 +0800 |
Manos, I think you may have miss reading my original message. The javascript error is caused by the transformation. Mozilla seems to think 'document' = the untransformed 'XML Document' and not the output transformed HTML document. Also, this is just talking about situation (1)... how about situation (2) >-----Original Message----- >From: Daniel Joshua [mailto:daniel.joshua@xxxxxxxxxxxx] >Sent: Monday, 26 July, 2004 12:46 PM >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >Subject: [xsl] Any samples of client-side XSLT to generate webpages? > > >Hi all, > >I am looking for samples (hopefully as part of a web site) >of web pages that use XSLT in a browser to generate the HTML >that is displayed. > >Best would be pages that have forms. As I am encountering a problem >trying to submit a form in Mozilla using 'document.myForm.submit()'. >When I did a alert() to see the value of 'document' it returned >'XMLDocument' and 'document.forms' returned 'undefined'. > >Currently, it works in IE using client-side transformation >(ContentType: "text/xml") and in Mozilla using server-side >transformation (ContentType: "text/html"). > >Also, I noticed in Mozilla's DOM Inspector that my '#document' had >two 'html' child nodes, the first was blank and the second had the >'head' and 'body' nodes and the namespace 'http://www.w3.org/1999/xhtml'. >Any idea for this extra 'html' node? > >I really would like to examine how other people do XSLT in browsers, >thus the reason I am looking for samples. Or should I do all my >transformation on the server-side? > >By the way, I am using Mozilla 1.8a2 and IE 6.0. Thanks for looking into this. :) Regards, Daniel -----Original Message----- From: Emmanouil Batsis [mailto:Emmanouil.Batsis@xxxxxxxxxxx] Sent: Tuesday, 27 July, 2004 11:30 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Any samples of client-side XSLT to generate webpages? Daniel Joshua wrote: >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. > >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 > > That's a javascript error. Just go to Tools > Web Development > JavaScript Console and you'll see what the problem is; you have to use DOM properly to submit the form. formName.submit() only works in IE, you should use document.forms or getElementById etc. Clearly not an XSL issue ;-) MAnos -----Original Message----- From: Daniel Joshua [mailto:daniel.joshua@xxxxxxxxxxxx] Sent: Tuesday, 27 July, 2004 11:15 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Any samples of client-side XSLT to generate webpages? 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Any samples of client-sid, Emmanouil Batsis | Thread | Re: [xsl] Any samples of client-sid, Emmanouil Batsis |
Re: [xsl] Any samples of client-sid, Emmanouil Batsis | Date | Re: [xsl] XSL resources - Flat to h, David Carlisle |
Month |