Using XML / XSLT to render HTML in web apps


XML & Web services: Using XML / XSLT to render HTML in web apps

  1. Using XML / XSLT to render HTML in web apps (5 messages)


    I need your feedback on using XML to store the meta data and then render HTML using XSLT in web application. It will generate the web pages for the front end. We will have our custom tags which will be specific to application.

    Has anyone use XSLT for similar a large scale application.
    Are there any limitations for using XSLT in this way or is there a better way to do it..

    Appreciate your feedback.
  2. There are drawbacks of storing the data as XML in database:
    1) The search queries on the xml colum would take a lot of time
    2) For big XML files you may have to create a clob column and in this case you cannot do a where on a clob data.
    3) More than your data size the size of the XML tags would be greater... and hence a wastage of storage space (considering a large scale application)

    Assuming no where clauses are required on your XML data column...
    How would you work on the data retrieved from the database... 1) DOM manipulations - very costly
    2) Java Xml Binding (iam a Java guy) - unmarshall xml to Java... do the work... marshall java to xml ... apply the XSLT.

    Another totally different way of doing is...

    - Store the data in different columns, so that you can make all possible kinds of queries.
    - Get the data into JDO to work on the objects.
    - Marshall the JDO to XML
    - Apply XSLT on The Server Side or The Client Side

    With these options right choice can be made depending on the requirements.
  3. Hi Richa,

    Did you mean to store data in XML format in database ?
    Well from your words, I think you meant to store only metadata.

    With this assumption here are my 2 cents:

    1. Store the data in RDBMS.
    2. At server restucture the final renderable data in XML format.
    3. Give this XML to XSL for rendering the HTML pages.
    Here you have two options:
    3.1 Server Side XSLT:
    You can write jsp-tags to invoke the XSLT at server side and generate HTML output before it is piped to client.
    3.2 Client Side XSLT:
    You can perform XSL transformation at browser end by sending response in XML format with link to its rendering XSL. This solution relies on XSLT engine at browser end.

    You will have to take a call on these options. I personally recommend #3.1 since we can control the XSLT.

    Yes I have used XSLT in similiar scenarios and it rocks.

    Let me know if you want to know more.

  4. Domify[ Go to top ]

    I'm not sure I complete understand, but if you mean that the data to be displayed on the page has to be XML transformed by XSLT into HTML then check out Domify, one of the most useful libraries for working with Java and XML IMHO.

    Basically, you wrap your java model (eg. an object/map/collection) in a Domify adapter, which makes it look like a DOM model. You can then just pass it via a DOMSource into an XSLT transformation and refer to it using XPath.

    I have done this many times and it works fine. Spring supports this as well. It works even better if you precompile your transformation into a Templates object on initialisation. Creating new transformation objects then becomes very quick.


    You needn't be
  5. Thanks so much for your feedbacks.

    I forgot to mention that we use XML database, so persisting xml is not a problem. I am concerned about using XSLT for transformation to HTML/JSP. Ours is a huge web application which will be used by multiple users. So is it a good idea to go ahead using XSLT ?

    Thanks in advance.
  6. Hi Richa,

    As mentioned above, if you can precompile your stylesheets into Templates objects and then cache and reuse those, performance will not be a problem in principle.

    Remember that XSLT was designed from the outset to be a functional language and processing a functional language is much easier to optimise than a procedural language, so you will get better like-for-like performance.