• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using .xml and .xsl file in Servlets/jsp files to generate .html content (to browser)

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I can say ur help will be appreciated very well,Becoz ,We are at designing stage.
Is there any processer/parser to generate .xsl/.xslt files by accepting .xml files as input. If it is there , It is easier to generate .html files using XT processer. Becoz i am sick of writing .xsl .xslt and .html files from .xml files.
If i want to use this .html file in JSP file as presentation how should i approach?.
AND
How should i write a servlet/jsp file by using (.xml and .xsl/.xslt) files to generage .html content as output and input to browser.
Your help will be aprreciated.
raya.ku
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any processer/parser to generate .xsl/.xslt files by accepting .xml files as input. If it is there , It is easier to generate .html files using XT processer. Becoz i am sick of writing .xsl .xslt and .html files from .xml files.
Raya, it�s not clear what level of control you have on your XML and HTML files. Do you have predefined HTML file for each XML, so you have to convert to this particular HTML? If not, and if all you need is somehow show your XML, you can write one generic XSLT which will, for example, translate any element into <p>element content</p> or something like this.
If you do have predefined HTML, then I am not sure you can 100% automatize this task. There always will be need to tell an automat which XML tags corresponds to which piece of HTML. Perhaps there are tools which allow you to do it in run time via GUI or some kind of script, check this: http://www.xmlsoftware.com/convert/
Another possibility: if you have a control on how your XML files are generated, you can modify this process by including presentation information in XML document itself. This is described in XML Journal, vol. 2, issue 3, p.32
something like:

and then have one generic XSLT which will produce HTML output (or another XSLT, or even Java program; the article I mentioned describes Java program generation from XSLT )
How should i write a servlet/jsp file by using (.xml and .xsl/.xslt) files to generage .html content as output and input to browser.
Usually you simply call your XSLT processor and tell it your input XML and XSL files. For example with Xalan and Jakarta taglib you would write:

in this case resulting HTML will be inserted after <body> tag.
For more information you can read:
Using XML and JSP together By Alex Chaffee http://www.javaworld.com/jw-03-2000/jw-0331-ssj-jspxml.html
Serving XML with JavaServer Pages by Duan Yunjian and Willie Wheeler http://www.devx.com/upload/free/features/javapro/2000/08aug00/ww0008/ww0008.asp
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any processer/parser to generate .xsl/.xslt files by accepting .xml files as input.
What kind of xml files as input? Or do you mean what Mapraputa appears to think you mean and do you have .html templates/examples as a starting point? If not, and you mean what you write, there certainly is a processor which may be able to generate .xsl files from your .xml input. It's called XSLT (remember, an .xsl file is a valid xml file, and can itself be generated using a stylesheet). It may even be able to generate your .html. Whether it is feasible depends on what information is present in your .xml input.
I'd like to add that the Orion application server comes with Xalan and makes the XSLT processing very smooth indeed. Just code your JSP to generate XML with the appropriate stylesheet link. Orion comes preconfigured to recognise this, puts it through Xalan and sends the generated HTML to the browser. When I first started to dabble in XSLT, I thought that was incredibly cool
- Peter
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mapraputa Is:
[...] if you have a control on how your XML files are generated, you can modify this process by including presentation information in XML document itself.


Mapraputa, doesn't this ruin the division of responsibilities between the stylesheet and the XML files? Presumably, the stylesheet is there to generate the visual formatting. By including presentation information in the XML file, you start to couple the XML file pretty tightly to the layout and you lose all the advantages of an XML + XSLT -> HTML setup. Or am I missing something?
- Peter
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter, thanks for disagreement
I think that XML + some metadata about how the data should be rendered is not so bad design decision. It�s something between 100% data + layout coupling and 100% separating. By putting such information in XML document we do not actually tie data to representation, it�s still possible to have various XSLT which will simply ignore this meta information and produce any other desired output. We just provide recommendations (or, if you want, default representation) how data could be shown.
I suggested such trick based on Raya�s wish to get rid of XSLT creative writing process Unfortunately, we do not see the whole picture: what all those XML document came from? Do they all have different structure? What kind of processing is required to show them as HTML? If there is no need to select/rearrange elements, then CSS would suffice. Raya, if you could give us more information, we hopefully could say something more appropriate to your task.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic