This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Using XSL Transform on Java Beans with Lazy Loading?  RSS feed

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, here's my problem:

We currently use XSL Templates for generating our web site. Most of the web site is fairly simple, though there are a couple of pages that aren't. These pages tend to need to load a huge amount of data from the database, representing various things. However, depending on the permissions of the user opening the page, they may not need all of it. e.g. the user may only be allowed to view the Applicant's First Name, Surname, DOB, etc, but not their address or financial history. Given that, loading and converting this information to XML is a complete waste of time.

However, there's a problem with that: I can't see a way to use a Java Object as a Source for an XSL Transformation without having to convert it to XML in some way.

I have had a look at JAXB, but while that's very close, it's not quite what I'd like - basically, it converts the entire object graph into XML, without any knowledge of whether that part of the object graph is being used or not, but at least it only needs to traverse the object graph once, as opposed to our current approach, which traverses the object graph once to create the Document, and then has to traverse the Document again during the transform.

Is what I want to do possible? Or am I completely SOL?

For reference, I'm currently using the following libraries/JEE Container/JDK:

Xalan 2.7.1
Xerces 2.9.2
Glassfish 2.1.1
Sun Java 6

So if there's better libraries out there that I should be using, I'd like to know.

Anyway, if I can't, then there's other options:

  • Use JSPs or similar.
  • Use AJAX for the most expensive and yet least used data.
  • Write a custom framework around, say, JAXB that does what I want, probably coupled with a custom XSL Transformer...

  • Of those, the second is probably the most likely. But if there is a way to use Lazy Loading and XSL Templates, I'd really, really like to know.

    Thanks all.

    - Andrew Thorburn
    Posts: 23867
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    "Andrew Th", please check your private messages regarding an important administrative matter.

    Thank you.

    As for your question, I wrote a website driven by XSL Transform a few years ago, and my interface from the database to the transformations consisted of a stream of SAX events. You might give that a try.
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!