|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
XML Protocols Building a Flexible Presentation Framework
Building a Flexible Presentation Framework
Nov. 25, 2002 12:00 AM
Information interchange has become key to survival in an increasingly wired world. It is in this context that industries have adopted XML as the enabling mechanism to achieve application integration. XML is ideally suited for designing a Web application that has multiple pages, some of which display common business information. If XML can be used to represent the application's business information, then XSL can be used to transform the XML for each of these pages. While Web designers can design the pages for the Web application, they can't be expected to design XSLT stylesheets. Stylesheet designers, on the other hand, are good at embedding transformation logic but are not conversant with writing HTML code or presentation tricks. This makes it hard to write XSLT stylesheets that transform the XML to HTML specific to each page. If Web designers can add special "tags" as placeholders for content, then those tags can be transformed at runtime using stylesheet rules. This article will address performance, flexibility, and ease of maintenance in the context of a framework that combines the capabilities of Java servlets, XML, and XSLT to present business information as Web pages to an end user.
The Basics XHTML is well-formed HTML. The loosely defined HTML specification can introduce interpretation problems to the browser and make it harder for HTML writers to validate the correctness of the HTML pages. Most browsers today attempt to interpret and render incorrect syntax in HTML pages, but sometimes the interpretation can be completely incorrect. This causes the rendered pages to be meaningless to the user. XHTML helps solve this problem since it requires HTML to be well formed. This means XHTML writers could validate their documents before publishing them. XHTML browsers can render XHTML documents correctly, eliminating the guesswork. Therefore, users can rely on the correctness of the document that is rendered by the browser. XSLT is a high-level declarative language, intended for transforming XML documents into other XML documents. XSLT expressions are used to describe rules for transforming XML documents.
The Problem Both the Web designer and the Web application developer have to coordinate through the entire development of a Web application, modifying the same set of Web pages, typically as HTML or JSP pages. Changes to the Web pages by one person usually affect the other. For example, if a Web page designer changes the layout of a Web page, he or she might accidentally delete the work done by a Web developer. Or, changes to a Web page by a Web developer might also accidentally cause changes to the layout. If these people don't work for the same company, sharing the same set of Web pages during development can pose a very difficult problem. Also, maintaining HTML Web pages is challenging, since HTML pages aren't easy to validate because well-formed HTML syntax is not guaranteed. Changes to HTML pages could potentially render them unusable or cause them to display differently on different browsers.
The Architecture Requiring that the page be produced in XHTML instead of HTML can solve the maintenance problem of HTML pages. If Web pages are produced in XHTML, it can validate syntax correctness easily using various tools. This will guarantee that changes to Web pages do not render them unusable or cause them to be rendered differently by different browsers. By introducing special tags to XHTML pages, the Web page designer can concentrate on design, without worrying about sharing Web pages with the Web application developer. These special tags are invented as a contract between Web page designer and Web application developer. At the beginning of and throughout the development of a Web application project, both the Web page designer and the Web application developer agree upon a set of special tags that the Web page designer needs for designing Web pages and the Web application developer needs to supply to the Web page designer. The Web page designer inserts these special tags into XHTML pages, where data supplied by the application program will be populated at runtime. The Web application developer references these special tags in the application code. A common XSLT stylesheet is developed to transform these special tags in the final process. After Web page designs have been finalized, the Web designer and the Web application developer together define what data needs to be used and in which Web pages. Then, they define a set of data needed for each Web page. Along with the data for each Web page, names of all data are uniquely defined. The Web page designer uses special tag "fields" as placeholders for each type of data needed in a Web page. An attribute "name" of each "field" is used to uniquely define each data element in each Web page. (See bold lines in Listing 1, XHTML Web Page.) The Web application developer develops a corresponding XML template for each XHTML Web page. (See bold lines in the example of a corresponding XML template, below.)
<template> The Web application developer writes application code to retrieve data and references these field elements in the corresponding XML template. At runtime, requests from the browser to the Web application result in invocation of the corresponding piece of application code, which in turn retrieves the needed data and inserts it into the corresponding XML template. A simple XSLT rule is used to insert this XML template into the corresponding XHTML document. A final transformation using a common XSLT is used to transform this XHTML into an XHTML document that is understood by the browser. This final XHTML document is then returned to the browser.
Discussion For easy and rapid Web application development, a tool can also be developed for the XML template and can generate the application code using information from the generated XML template to insert the data element into the XML template. This will reduce the requirement that the application developer has to know XML and XSLT and reduce development time because the application developer writes less code and, of course, there are fewer bugs to find and fix.
Conclusion
Resources Reader Feedback: Page 1 of 1
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||