Proceed to WirelessDevNet Home Page
Publications, e-books, and more! Community Tutorials Store Downloads, tools, & Freebies! IT Career Center News Home
newnav.gif

Newsletters
EMail Address:



   Content
  - Articles
  - Columns
  - Training
  - Library
  - Glossary
 
   Career Center
  - Career Center Home
  - View Jobs
  - Post A Job
  - Resumes/CVs
  - Resource Center
 
   Marketplace
  - Marketplace Home
  - Software Products
  - Wireless Market Data
  - Technical Books
 
   News
  - Daily News
  - Submit News
  - Events Calendar
  - Unsubscribe
  - Delivery Options
 
   Community
  - Discussion Boards
  - Mailing List
  - Mailing List Archives
 
   About Us
  - About WirelessDevNet
  - Wireless Source Disks
  - Partners
  - About MindSites Group
  - Advertising Information
 

The Mobile Developer

by Eric Giguère

Separating the Content From the Presentation Using XML and XSL

If you read any good book on software engineering or architecture you'll know that it's considered a Good Thing to separate an application's data from its presentation. You'll often hear this idea referred to as the Model-View-Controller (MVC) architecture, where the model represents the data, the view is the presentation, and the controller is the user input. Java's Swing user interface components use a modified MVC architecture, for example, and so does Microsoft's MFC C++ framework.

MVC-style programming takes some discipline, because you have to be careful to keep the model and the view separate. If you do it properly, however, it can pay off in the end -- especially when you suddenly have to add a new kind of view to meet customer or management demands. Kind of like the problem you face in adding HDML or WML support to your existing HTML applications, isn't it?

It's hard to retrofit an MVC architecture onto an existing application that wasn't designed that way, so chances are you'll have to rewrite your web applications to make them into wireless web applications. If you can spare the time (hard to do, I know, when your boss is urging you to get the "wireless apps" out there as soon as possible), try to separate the content from the presentation. One way to do this is to use XML and XSL: define your content in XML and control its presentation with XSL.

XML is a standard for defining tagged data and XSL is a standard for transforming XML data from one format to another. You can find out more about them at the World Wide Web Consortium (W3C) website, or you can pick up one of several books. Three that I personally like are XML By Example, Applied XML: A Toolkit for Programmers and Professional Java XML Programming with Servlets and JSP, but in all honesty the reviews on these are pretty mixed -- it looks to be very hard to write an XML book (especially a practical one) that pleases most people. One thing to note is that XSL is a very recent standard -- or recommendation in W3C terms -- and so only books coming out now would be discussing the final version of XSL.

While you're exploring XML and XSL, take some time to look at XHTML 1.0 as well. XHTML is a reformulation of HTML as an XML language. Ideally, you should be outputting XHTML instead of HTML when targeting conventional browsers. Of course, few browsers support XHTML yet, but Appendix C of the XHTML specification shows you how to write XHTML that can be read by an HTML-only web browser.

After picking up some knowledge about XML and XSL, wander over to the Apache Software Foundation (ASF) website. Although the ASF is known mostly for the popular Apache web server, they also run the Apache XML Project, which includes free XML parsers and XSL processors.

One of the more interesting aspects of the XML Project is the Cocoon framework for publishing web content. Cocoon is a Java servlet that you install on your web server, configured to handle all requests for XML files. Cocoon will automatically apply XSL stylesheets to transform those XML files into an appropriate format for the type of browser/device making the request. You can even use an XML language called XSP to define XML-based web pages with embedded Java logic to create dynamic pages that can also be further processed with XSL. If you're going to be generating HDML or WML content, it looks like Cocoon is a great place to start.

Of course, don't stop looking around at other alternatives. One good thing about HDML and WML is that it's forcing web site authors and developers to rethink the way they write and deliver web-based content and applications, so you can expect to see more and more XML-based tools appear to solve these kinds of problems.


Eric Giguère is the author of Palm Database Programming: The Complete Developer's Guide and an upcoming book on the Java 2 Micro Edition. He works as a developer in Sybase's Mobile & Embedded Computing division. Visit his website at www.ericgiguere.com or send him mail at ericgiguere@ericgiguere.com.

Sponsors

Search

Eliminate irrelevant hits with our industry-specific search engine!









Wireless Developer Network - A MindSites Group Trade Community
Copyright© 2000-2010 MindSites Group / Privacy Policy
Send Comments to:
feedback@wirelessdevnet.com