File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Should XSLT reside in Dynamic Web Project or Database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Should XSLT reside in Dynamic Web Project or Database?" Watch "Should XSLT reside in Dynamic Web Project or Database?" New topic

Should XSLT reside in Dynamic Web Project or Database?

Jon Greenwood

Joined: Mar 13, 2011
Posts: 15

My boss asked me a really good question yesterday, "Is XSLT data or code?".

We have a J2EE application that retrieves XML data from a database which is then sent on to customers.
Before being sent onwards it may have a stylesheet applied to it to transform the data.

There are less than 10 stylesheets and there will not be more (so no need to future-proof application).

Given these circumstances, should those stylesheets be retrieved from the database (are they data) or should they reside in the Dynamic Web project (are they code).

Either solution will work but can anyone guide me as to a preferred Design Solution?

Thanks in Advance
Matthew Brown

Joined: Apr 06, 2010
Posts: 4543

I'd say they're definitely code. Look at it this way - if you make a change to an XSLT file and get it wrong, you've broken the application. They've got the same status as any other application source code. I think the purpose of the file is more important than the fact it happens to be in the form of XML.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I would be agnostic as to whether an XSLT file was data or code -- I might even be convinced to call it configuration. But as soon as "data" means it's going in a database, then no. It isn't data.
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

I'd say store the XSLT on the file system. It just as easily accessible and I'm guessing (guessing mind you) that it may also be faster, also you may not want to waste the tablespace. That is unless you've got a complex scenario going on where you also store meta-data about the XSLT (e.g. versioning) and are updating both frequently. In that case, if you store meta-data in the DB and the XSLT as files on the file system, and updates are part of a larger overall transaction that is prone to rollback (due to optimistic locking for instance) keeping the filesystem and DB in synch could get complicated.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
I agree. Here's the link:
subject: Should XSLT reside in Dynamic Web Project or Database?
It's not a secret anymore!