Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly
get the code
more resources

Create a Template-Based Web Site
Use XML and XSLT to manufacture custom HTML
on demand.

by Jonny Anderson

December 2002 Issue

Technology Toolbox: XML, XSLT, ASP (VBScript)

ADVERTISEMENT

Building a Web site can often be an exercise in compromise. Combining multiple users' aesthetic and functional requirements tends to blunt any project's cutting edge. The power to generate HTML on demand is the sword to slay this "one size fits all" beast. Combining XML, Extensible Stylesheet Language Transformation (XSLT), and HTML enables your Web site to be more responsive to its client environment, more focused on its specific functionality, and more persuasive to its users. The benefits of scalability and flexibility act as a power-multiplier, extending the reach and reuse of your HTML.

This article shows you how to create a template-based Web site. The sample that accompanies this article is a skeleton e-commerce site for the fictitious Not For Sale Company. The Web site allows the user to select a product from a dynamic catalog that lists each product using a thumbnail image and short description (see Figure 1). After selecting a product and entering a few details, the user can confirm a dummy order that triggers the automatic dispatch of an e-mail to the user (see Figure 2). The generated e-mail contains a unique link back to the company Web site that allows the user to track his or her particular order's status

Figure 1. View a Table of Thumbnails.

(see Figure 3). Notice that this Web site contains no static HTML pages. The design is flexible because the Web content is generated on demand. (For a brief introduction to XSLT, see the sidebar, "Deliver Targeted Data With XSLT.")

A template-based Web site consists of a data source and a series of page templates. Each template represents a generic Web page with gaps you can fill with data from a data source. Unlike normal HTML pages, you must merge a template with some data before it's ready for viewing. This extra processing step allows each page to be partially or entirely generated according to the needs of the individual user who requests it. XML and XSLT complement one another in this process: You use XML to create the data store(s), and you use XSLT to write the templates. The Microsoft XML Document Object Model (DOM) provides the objects you need to merge XML data with XSLT templates to create HTML Web pages on demand. So, a template-based Web site generally consists of three types of files: Active Server Pages (ASP or ASPX), page templates (XSLT), and data files (XML).



Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home