A simple document generation system using ASP and XML that anyone can use
 


by Jason Salas, KUAM.COM
November 25, 2001

 

Past editions:

Password-protect your Web work

Error Handling in VBScript

Creating a banner ad rotation system

The Web-safe color palette for developers

Time-saving Windows shortcuts

Analyzing your site's traffic logfiles

Technologies Used:

Summary

Objectives

Level of Difficulty

Download the tutorial documentation and source code for this project

Making Web publishing easier
It's the intent of software to make you work smarter, not harder.

One of the biggest challenges that traditional companies face when just starting to embrace the online revolution is the publishing aspect of getting their content online (which for them, being newbies, can be a monstrosity of a challenge). Traditional Web authoring mandated that a content author would have to know the intricacies of HTML - which largely ruled out any staffers except for progressive MIS programmers or a few daring advertising and creative people - who also has to be savvy enough to know how to get their content online, like via FTP.

As the Web continued to mature, more and more people began to pickup on how to create HTML documents, but simultaneously Web access became available from beyond the confines of the normative PC (mobile devices, Internet appliances, etc.) making publishing quite complex in terms of the creation and management of content. Controlling such a system is beyond the normal capacity of most organizations today.

Since I currently manage a Web site for which local news information is the prime attraction, it's important to me to be able to let our content producers easily get their work up online - quickly - without forcing them to actually write complex code (which they shouldn't have to do), and without me having to do the work for them (which I shouldn't have to do). Its part of our responsibility as developers to design and then deploy our applications, and then move on to the next thing…and not become slaves to them, doing manual data entry and updating.

In this lesson, we're going to build a very simple document management system, which anyone in the office can use, thus freeing up your Web staff (in this case, you) to work on other projects. We'll be using XML documents to hold our core data - in this case, news articles - in combination with scripting within Active Server Pages to present the content nicely. I use a system not unlike the one we're about to create for running some aspects of our newsroom; you might use it for company newsletters, product examples, or your personal listing of your favorite episodes of "The Transformers". It's completely adaptable.

Letting your content get the most out of the Web (without breaking your back in the process)
When I was mapping our site and its features in my head early on, I theorized that to really be a superior competitor we would have to have our information available in a variety of formats (HTML for our public site on the World Wide Web, on mobile devices such as Palm Pilots, PocketPCs, and advanced mobile phones through WAP, on alphanumeric pagers, through push channels using RSS, and so on). I envisioned us having to have our data centralized and single-sourced, so as not to force an author to write one story six separate times, in six different formats.

It was also an interest of mine as a marketing tactic to develop a syndication service for our content and have our news content portable, so that our headlines could be implemented easily on other sites external to ours. I was also interested in getting our articles well recognized by the major search engines like Google and Excite, as well as by search directories such as Yahoo! and Snap. Database-driven sites that generate querystring-based URLs (i.e., http://www.domain.com/filename.asp?id=8675309) aren't always crawled by search engine and search directory spiders which results in pages not being indexed with the Web's major search services, which is a negative factor in getting your site recognized and marketed. Thus, I wanted to create a system that would output our stories in individual files that search services would be able to crawl and list better.

Enter XML.
 

Download the tutorial documentation and source code for this project


Choose your weapons carefully…
OK, so it's not as dramatic as selecting pistols at dawn, but it's important to know the capabilities (and limitations) of the technologies you're application is based upon. I chose XML (eXtensible markup Language) as the fundamental data technology because of its universality, and the fact that we can take a single document, and have it ported to different platforms (our public Web site, our mobile channels, our portable headlines) through the use of a number of written in XSL stylesheets (eXtensible Stylesheet Language). The management of the various formats for the document is simple.

I use Active Server Pages (ASP) as the presentation platform because it supports a very simple script construct that lets us display the data in an XML document, according to formatting defined in an XSL stylesheet:

<%
' Load the XML document
Set source = Server.CreateObject("Microsoft.XMLDOM")
source.async = false
source.load(Server.MapPath("an XML filename"))

' Load the XSL stylesheet
Set style = Server.CreateObject("Microsoft.XMLDOM")
style.async = false
style.load(Server.MapPath("an XSL stylesheet"))

' Write out the page contents
Response.Write(source.transformNode(style))

' Destroy all object references
Set source = Nothing
Set style = Nothing
%>


The script instantiates the Microsoft XML Document Object Model (MSXML DOM) twice, once for the XML document containing our story data, and once for the XSL stylesheet we're going to apply to it. The end result will be a file with the extension of .ASP, with the data in the XML document presented as HTML.

ANALYSIS OF FUNCTIONALITY
What this system makes possible is multi-platform publishing. Remember here that they key to make this app work is to make the core asset - the data - the key ingredient, and not limiting ourselves to a single method of presenting that data and likewise not imposing on ourselves the monstrous task of creating separate pages for multiple platforms (in my example, our public Web site, mobile device channel, push channel, external portable service). This makes expansion easier.

If we choose, we can also make this data available to be ported to other partners, who in my situation might be network news providers or local affiliates. They can take the core data in the XML documents and write their own formatting schemes using XSL's transformation language (XSLT) to have the XML data work according to their own system's specifications, and then apply XSL's formatting objects (XSLFO) to have it match their own color schemes, layout, etc.

The way this system works is by:


Download the tutorial documentation and source code for this project

Have fun using this in your own projects!