Implementing Dynamic Web Interfaces Using XSLT
page 2 of 4
by Gil Shabat
Feedback
Average Rating: 
Views (Total / Last 10 Days): 27281/ 48

Planning for Dynamic Content

Whether you are in the process of building a new business web application or planning to build one, you most likely need to address how your web application will handle displaying different content for different users.

Considerations

When considering the different options for displaying dynamic content you generally need to take into account the following aspects:

Usability

Usability might be one of the most critical aspects in the success (or lack thereof) of your application.

Development Time

This includes the total amount of development time involved in satisfying your current application requirements.

Flexibility

Regardless of how comprehensive your current requirements are, applications tend to evolve over time. It’s important to evaluate the development effort and skill sets required to accommodate changes.

Support, Maintenance & Ongoing Enhancements

Commonly ignored by many when planning new development projects, it is generally responsible for a good chunk of the total cost of an application over the span of its life. This includes bug fixes, client customizations, minor application enhancements and of course, QA and testing.

The Options in ASP.Net

Generally web applications that use ASP.Net have two main options for displaying dynamic content:

Server Controls

With Binding – retrieving the relevant data and binding it to the appropriate ASP.Net server controls on a web form

In Code – populating the appropriate ASP.Net server controls in code

HTML

In Code – constructing the HTML to display in code  based on the information retrieved from the database

Using XSLT – retrieving the database information in XML format and then transforming it into HTML with XSLT

A third option is Silverlight, a relatively young technology introduced as an option for web applications by Microsoft about a year ago.  Silverlight provides a very rich GUI with the power of the .Net platform (a subset, actually) and tools that make web application development quite similar to the latest Windows application development (WDF). 

Comparing the Different Options

Before you decide on the best route to take to display dynamic content you need to evaluate the impact of each approach on your application. You might find the table below helpful when making this decision.

Approach

Pros & Cons

Best Suited For

Server Controls

 

 

With Binding

The quickest approach in terms of development time but also the least flexible.

Best suited for applications with low data complexity and that are not expected to change often.

In Code

Hooking up the controls in code takes longer in terms of development but is much more flexible than binding.  This approach also requires a higher level of support and maintenance.

Best suited for applications with high data complexity and that are not expected to change often.

HTML

 

 

In Code

Constructing HTML in code gives a good deal of flexibility over the markup that’s created but is time-consuming and extraordinarily brittle.  This approach requires extensive testing and support.

I wouldn’t recommend this to be used as a general strategy for web applications but at times this might be used for particular sections depending on a unique set of requirements.

Using XSLT

Offers high flexibility and the least amount of ongoing maintenance and testing.  The development time might be longer depending on your team’s skill set.

Best suited for applications with high data complexity and ones that are expected to change significantly and frequently. In addition, this allows for a lot of room for creativity as far as interface design goes.

Silverlight

Provides the richest GUI possibilities and the complete separation of interface and code.  The time to develop, test and support are currently higher than other options.

Best suited for applications that require very rich user interfaces, and for development teams that primarily focus on Windows development.

 

Real-World Use Case: Scopings

When we started evaluating the requirements for Scopings, our homegrown recruiting platform, we needed a way to present complex content with a unique look and feel, a high level of usability, an infrastructure that can easily adapt to frequent and substantial changes, and built-in capabilities for globalization.

Very quickly we realized that although we can use ASP.Net server controls to build the first revision of Scopings in a relatively short period of time, this wouldn’t adapt well to the frequent changes we expected to be an inevitable part of the product lifecycle, and it would therefore, substantially increase our total cost of ownership.

After much analysis and many discussions, it became clear to us that designing our own infrastructure for constructing HTML using XML and XSLT would satisfy all of our requirements.  We sat down and started to design an infrastructure that has ultimately been used for more than 80% of the functionality on Scopings.

Constructing Dynamic Content

The idea behind the Scopings infrastructure was to allow us to make substantial changes to our user interface, while eliminating the need for any code changes and development staff involvement, and substantially decreasing the amount of QA required following any changes to the user interface.

To accommodate these requirements the Scopings infrastructure was built to be completely indifferent to the information retrieved from our database and to the way the information is ultimately displayed.

To achieve this we designed the infrastructure as follows:

- A separate stored procedure was built against each web content page to be displayed, and was designed to only output XML.

- Upon loading a web page, we used XSLT to transform the XML received from the database into HTML and display it for the currently logged-in user.

- All HTML styling was handled with CSS.

Given the above approach, any change to the way we display data, or to the content of the page would only involve the following minor modifications:

- If any additional data is needed we would modify the stored procedure to include the new data required. If no additional data is needed, no change to the stored procedure will be made.

- Modify the XSLT to include any new data to be displayed, and any changes to the display.

- Modify the corresponding CSS files to make any changes required for styling.

- Test display changes and specific page functionality if any.

This allows for content and interface changes that require little to no development efforts and can be done very quickly with minimal testing.


View Entire Article

User Comments

Title: Question   
Name: Pravin
Date: 2009-05-22 3:14:32 AM
Comment:
Excellent article, But can you please tell in this approach will it be the best if performance is the key of the project. Thank you.
Title: Excellent Article   
Name: Daniella
Date: 2009-04-07 4:17:05 AM
Comment:
This way is my favorite way to display data from database and xml. I just love xslt :)
Title: Is there any download of this project available.Please reply   
Name: Mohammad hussain
Date: 2009-04-03 5:43:44 AM
Comment:
Is there any download of this project available.Please reply me back on mohd786hussain@yahoo.co.in
Title: Dynamic Web Interfaces Using XSLT   
Name: HoyaBaptiste
Date: 2009-03-18 5:15:55 AM
Comment:
@Morten - You can do equally bad thing with controls. I have found XSLT more flexible especially in situations that would require nested repeaters.

FYI, to separate layers, you can put XHTML in a template (VIEW) (*.html) file and "bind" data (MODEL) as xml with the template using xslt. In this scenario, xslt is the data binding "glue" replacing xml "tokens" in xhtml with data from XML. Implemented this way, XSLT driven "views" can prove maintainable and easy to understand... once you see the pattern.

@Johnny - There are some Math functions you can do in XSLT. You can pass in values and objects (properties and methods must return simple types). For example, from an ASP.NET you could pass a UserPrincipal / UserIdentity and check "IsInRole" within your transform to "show/hide" a region of html.
Title: Maintenance hell   
Name: Morten
Date: 2009-03-18 3:32:39 AM
Comment:
If you wish to go down this road of creating user interface via xslt, _be sure you document your work_! I myself recently faced maintenance hell when I had to take a project like this over from a guy who quit his job. He had documented next to nothing, and bear in mind xslt is not a markup you would read line by line, off the bat. It _will_ take a long time to get acquainted with this code and markup, certainly as long as it took to write it in the first place if there's no documentation covering it.
Title: Good article   
Name: Johnny
Date: 2009-03-18 12:02:39 AM
Comment:
This article is really useful for developers and anyone wanna build a flexible dynamic website.
But i wonder, if i wanna do somthing like calculate, check...data before displaying to user, how can i do with this approach?
Title: Provide references   
Name: Sirish
Date: 2009-03-17 10:32:31 AM
Comment:
Please provide references to different classes used in the code.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-26 2:03:13 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search