XML and The Dynamic Contents Approach - Part IIAs you have seen in Part I, the contents of homepage are dynamically updated - based on the XML database. In this article, we will go one step further that is: dynamically displays full article according to user's choice. What I mean is when Internet users click on More... link, the new page will be created (virtually) instantly which shows all the details of the article. Of course we need to do a bit of planning, right!
Design a template and specify the hot spotWell, since we already created the welcome page for our website (see Part I), we simply reuse it. Of course a minor modification is needed. Let's say we have a final layout for full article to be displayed in is:
See Demo. To be able to show full article like this, I am going to use the stylesheet XSL to format the output. Design an XSL stylesheetThe idea of using XSL stylesheet is to separate the data and the formatting is for future maintenance. If we would like to update/change the presentation of the webpage, we know where to modify it without touching the data and vice versa. The stylesheet itself is very simple, what it does is actually select the article title and story tags to display, let's name this formatting technique is articles.xsl.
See the stylesheet above with HTML format embedded. Building a bridge?From the main page, when you click on More... hyperlink, we deliberately passing the article id, and calling the process.asp file to catch and handle it...I am calling the process.asp script is the bridge. Why? Because the XML data (articles.xml) and the formatting XSL (articles.xsl) are two independent elements. Thus, a technique that use to combine them together is needed...See the process.asp code below...
From the code above, you could tell that I wrote something rather more than I should...Of course, you don't have to use Select Case but...just keep in mind that it is a good practice to develop something that you or other people can be re-used, maintain/implement the codes easily in the future... Download the source code! |
| Copyright © Vovisoft October 2001-2002 |