Welcome Guest!
Create Account | Login
Locator+ Code:

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

email article
printer friendly
get the code
more resources

Infinite Web Pages from One ASP
Generate infinite HTML pages on a single Web site with one ASP rather than two, courtesy of object-oriented features in .Net
by Andrew C. Mayo

Posted April 1, 2003

Two years ago I created a Web site composed of two active server pages (ASPs) that could produce an infinite number of HTML pages (see Resources for a link to the article). I used this technique because I wanted a Web site for my XML course that was scalable, maintainable, and able to showcase XML technology in action for my students. Now, taking advantage of its object-oriented (OO) features, I've recoded that Web site with .Net and ported it to a single ASP.Net page. The technique I used is useful for those who want to unravel the XML transformation aspects of .Net, as well as for those who are interested in using a design pattern that permits creating a scalable Web site with one ASP.Net page containing just three lines of code. This technique also is useful as a piece of a Web site that performs XML-to-HTML transformations as part of its processing.

ADVERTISEMENT

XML is about data, and the technologies surrounding it can be segregated in three categories: configuration, messaging, and transformation. You can find examples of the flexibility of XML files using application configuration information such as saving user preferences in a Windows application or the web.config file in ASP.Net applications. The messaging/data transport mechanism of XML is found through such technologies as Simple Object Access Protocol (SOAP), Web services, and the disconnected recordset object or data set in the .Net platform. Transformation exists with the Extensible Stylesheet Language Transformation (XSLT) standard, which serves as a means of transforming XML documents into other text-based formats. XML's configuration and transformation categories are the key ingredients for the construction of the Web site example described here. An XML file containing configuration information constructs the site, which is presented to the user through server-side transformations of XML into HTML.

In my first article, I mentioned a similarity between an Internet site diagram and an XML document. Both are hierarchical and depend on a root. Thus, I could structure an HTML Web site using an XML document. Page elements within an XML document represent the pages. The Page element contains attributes that state the page's identification, its name, and whether the page is active. This element has subelements (doc) attached to it that state where the data for the page is located (type="xml") and also where the transformation of that data is located (type="xsl"). The configuration information has this structure:

<Master>
<Page active='Yes' default=
        'Yes' MainMenu='Yes' id="P00" 
        Name="Home">
<doc Type="xml" URL=
        "\xml\home.xml" />
<doc Type="xsl" URL=
        "\xsl\home.xsl" />
</Page>
…
</Master>

A Web site designed in this manner loads this configuration information as soon as the application starts and caches it for use in creating a page requested by a user of the site. The Web site also uses the information in this configuration file to create a common menu that displays on each page of the Web site. The common menu is a result of the transformation of the configuration file from XML to HTML, and it's also cached by the application.

In a nutshell, whenever a user requests a Web page, the application interprets the configuration information to find the requested page. If it's found, and if it's active, it then uses the doc subelements to locate the content for the page (type="XML") and the transformation instructions (type="XSL") of that content. These pieces, data and transformation, are combined through an XSLT transformation to create an HTML page that is output to the user.

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