Developing for wireless applications brings its own set of challenges, including a number of display and browser issues. In this three-part series, I’ll explain how to use the Java APIs for XML Processing (JAXP), along with XML Stylesheet Language Transformation (XSLT), to solve some of those problems and build content that the wireless device can understand. I’ll kick off the series by reviewing a few of the basics to show you what you’re up against and where JAXP/XML/XSLT will come in handy.
Back in the old days (does anyone remember 1994?), the cutting-edge technology was client-server GUI development with languages such as Visual Basic and PowerBuilder. One of the problems with early GUI development was that you never knew which monitor resolution to program for. If the application was viewed on a monitor using 800 x 600 resolution, it would not fit on desktops using a lower resolution. If the monitor resolution was high, your applications would be too small to see.
Internet development partially solved this problem. By using markup tags to define the GUI, the application could use more of a relative, as opposed to absolute, positioning. This meant that the GUI would resize somewhat when the user resized the browser. By default, Java applets also use this system of relative positioning.
So what’s the point? Screen resolution problems are an even larger issue on handheld devices. High-end PDAs such as the Handspring Prism have a resolution of 160 x 160 pixels—a far cry from traditional monitors that have a resolution of five times that much. Mobile phones, on the other hand, are on lower end of screen resolution. A Nokia 6185i has only five lines of resolution. So what do you do? Write completely different applications for each device? That’s not really feasible. But, by the end of this article, you’ll see how you can use JAXP/XML/XSLT to regulate what content gets served to which devices.
With few exceptions, wireless applications are run within a microbrowser. These browsers come in all shapes and sizes but all have the same purpose: connecting to the Internet. So a microbrowser serves the same purpose as its larger, full-featured cousins, such as Netscape Navigator and Internet Explorer. And, like its cousins, microbrowsers may have varying support (or no support at all) for certain markup tags.
As a result, just because a wireless application will run in one microbrowser does not guarantee it will work in others. To further complicate your day, dozens of microbrowsers are currently being used. Your job is to make sure that your wireless application works in all of them. Again JAXP/XML/XSLT will help you with this daunting task.
Remember that XML is a set of markup tags that describe the data, not the presentation (what the user sees). Almost never does the user see pure XML. XML is an intermediate technology that is transformed into viewable presentation tags such as WML or HTML. Where does the XML come from? Just about anywhere you want. It could be in something as sexy as a Java Byte Stream or as mundane as a flat file. Keep in mind that because XML is a new(er) technology, any language that can write flat files can generate it. (COBOL programmers are allowed to snicker here.) For the sake of simplicity, I will use XML in the form of a flat ASCII (read Notepad) file.
When XML needs to be viewed, it must go through a transformation. The transformation refers to reading the raw XML file and then stripping the XML tags and replacing them with markup tags that can be understood by the browser. In the case of traditional browsers such as Internet Explorer, HTML tags will be used. In the case of microbrowsers, WML tags will be used. The beauty of transforming XML to the desired markup language is that only a single XML file is required. The resulting data can be formatted differently depending on which browser is requesting it.
So what defines the transformation? Not surprisingly, you define the rules of the transformation. How you do this can vary, but for the sake of simplicity, we’ll place the transformation in a flat ASCII file. Most transformations are performed on the server in this fashion. Files that define the transformation rules are called style sheets and generally have an .xsl or. xslt extension.
At this point, you should have a good idea of the technologies involved in programming for wireless devices. In the next article, I’ll provide some simple examples of transformations that utilize the Jaguar server platform, getting more complex as I go. In the final article, you’ll learn how to build a robust wireless application using Jaguar.