Hi Alternatively, DOM4J could also help :)
----- Original Message ----- From: "Pugh, Eric" <[EMAIL PROTECTED]> To: "'Turbine Users List'" <[EMAIL PROTECTED]> Sent: Friday, January 04, 2002 10:45 PM Subject: RE: How to output XML as HTML nicely.. > Scott, > > Thank you for your code, I am going to play around with it. I think in the > short term I am going to go with the <PRE> tags.. In the longer term, it > seems that I may try and create an applet that mimics the functionality of > IE or XMLSpy using a JTree.. That will be another week though. > > Thanks for the thought provoking answers! > Eric > > -----Original Message----- > From: Scott Eade [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 04, 2002 6:07 AM > To: Turbine Users List > Subject: Re: How to output XML as HTML nicely.. > > > From: "Pugh, Eric" <[EMAIL PROTECTED]> > > I think that JDOM has the ability, if I set it up right, to produce a long > > text string with crlf's in the right places and the appropriate number of > > spaces to do: > > <doc> > > <element>hi</element> > > </doc> > > > > I am hoping that there is an easy as pie way, versus having to use ECS to > > parse through me JDOM object (which incidentally is what the XML is living > > in!) and figure out how many td to put in or spaces... > > > > I may end up just stripping the < and > characters and using some <PRE> > > tags, but not the best way... It does seem that there should be somesort > of > > method in Turbine's servlet, or in the Servlet API that would do the > > conversion for me, but I haven't found it yet successfully. > > Why not stick with using <PRE> and substitute < and > for < and > > respectively (with spacing provided by JDom as suggested). > > > Lastly, I looked around thinking there should be an applet out there that > > would give me a nice XMLSpy type interface that I could embed so you could > > browse the XML tree. No luck so far. Sorry about this posting starting > to > > get off topic, but if I do find a way, I will post it back to the list. > > It's not too hard to use a JTree over the top of an XML document but > I am not too sure about using swing components in applets. You would > probably have to write this yourself and you would need to be sure that > your target clients have a JRE configured. > > > Eric > > I know it is not what you asked for, but the following code will be > useful to anyone that wants to spit out some xml from JDom directly > to the browser (complete with xslt stylesheet): > > String stylesheetName = "http://www.mysite.com/xsl/somesheet.xsl"; > ProcessingInstruction stylesheet = new > ProcessingInstruction("xml-stylesheet", "type='text/xsl' href='" + > stylesheetName + "'"); > Document doc = new Document(someElement); > List docContent = doc.getContent(); > docContent.add(0, stylesheet); > > XMLOutputter outputter = new XMLOutputter(" ", true); > outputter.setTextNormalize(true); > > String filename = "someFilename.xml"; > > data.declareDirectResponse(); > HttpServletResponse response = data.getResponse(); > response.setContentType("text/xml; name=" + filename); > //response.setContentLength(outputter.toString().length()); // Not > very efficient > response.setHeader("Content-Disposition", "attachment; filename=" + > filename); > response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1 > response.setHeader("Pragma", "no-cache"); //HTTP 1.0 > response.setDateHeader("Expires", 0); //prevents caching at the > proxy server > outputter.output(doc, response.getWriter()); > response.flushBuffer(); > > If the client is IE 5.5 or above it will actually render the result of the > xslt transformation (alas this is not the case for IE 5.0 or Mozilla). > > HTH, > > Scott > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
