The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

JSP Generation From XML

It looks like I'm shortly going to be given the responsibility for the Web UI for a fairly large J2EE project.

I'm wondering whether it would be worth the trouble of creating an XML grammar for describing the pages at a higher-level and then using a single XSLT pass to generate the JSP source code. Has anybody done anything like this?

On the plus side, it would allow pages to be marked up in a higher-level, implementation independent way and the programmatic generation of JSP source code could eliminate a lot of errors and inconsistences. On the other hand, the XML grammar would have to be carefully designed and would be something else that developers had to learn.

Has anybody any experience or thoughts on this?
John Topley Send private email
Monday, March 14, 2005
Why don't you use the server side code(eg servlets) to create the xml stucture of your page, and apply formatting to it using XSLT?
You can also design an xsl stylesheet and output only the xml to the browser, leaving it (the browser) to do all the formating. I have used this technique (on a small scale project to be frank) and it has eased my development alot.

Monday, March 14, 2005
XML generating JSP sounds pretty awful to me.  We have a similar "solution" at my work for generating tests from our own homegrown text syntax. Some problems we have run into that you may also:

- Your custom syntax will not cater for as many scenarios as pure JSP does, so either people will have to spend time trying to find another way within your XML syntax, or you will be bothered with new feature requests.

- There is probably no IDE support for your homegrown XML.... sure there are XML editors, but if you want to code-complete or debug your XML, good luck.

The editor is the biggest one... but there is also a decent amount of work to be done just defining the structure. 

Also, this is potentially one of those lose/lose scenarios... best case is that even if you design the perfect solution, people will not be happy having to learn it.  Worst case is that it slows people from performing their job, or has lots of bugs.

I feel that JSP should only be used as a presentation layer... and personally would prefer a true templating system such as Velocity.  But, I realize you are inheriting this project, so perhaps this is not an option.

If you more clearly define the goals you are trying to achieve, or problem you are solving with your solution I would be happy to provide more feedback.

Good Luck,
Tom D Send private email
Monday, March 14, 2005
Thanks Tom, you raise some very good points and have convinced me that the idea is a non-starter.
John Topley Send private email
Tuesday, March 15, 2005
you should look at struts, especially the struts component named "tiles".

if you design your app well, you can define entire views via xml only. tiles can be extremely powerful. you can make huge changes across your entire site by just altering a few lines. i highly recommend it.

from the apache struts site:

Tiles builds on the "include" feature provided by the JavaServer Pages specification to provide a full-featured, robust framework for assembling presentation pages from component parts.
O.S. Send private email
Tuesday, March 22, 2005
We do something like this at work. If you simply want to go from xml -> jsp I wouldn't recommend. However, we use the xml to generate all sorts of stuff: java code, jsp, .xml configuration files, etc. It allows us to specify things in one place, and let the code generator do the menial work.

We don't use xslt for this, it's just a java program.
Monday, April 04, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz