Menu

More To WAP Than Meets The Eye

July 5, 2000

Didier Martin

If you thought WML was the de facto page markup language for the WAP, you'll be surprised to know that a lot of available WAP services are in fact written in HDML. This is especially the case in North America and Japan, where you'll find a good number of HDML rendering devices. But what is HDML?

HDML is an SGML application. In contrast, WML is an XML application. Both share the same elements--but some HDML elements differ from their WML counterparts by being packaged as "omit tags." As you know, in XML, a single tag element such as the <select /> element is ended with a "/". This indicates that the element does not contain data, and that it does not need a beginning and ending tag. It only needs a single tag.

The same element in the SGML world is expressed (without a "/") as follows: <select>. An SGML parser needs a DTD to indicate which elements are to be "omit tags." This is not needed in XML, since a standalone tag can be easily recognized by the "/" symbol. So, because the HDML element set is SGML-based, you can expect that some of its elements are omit tags and thus cannot be parsed by an XML parser.

You may think that only old digital phones include HDML browsers and that new phones have WML browsers. I was thinking the same thing too until I bought my new toy: a Neopoint 1000. I was surprised to discover that it wasn't displaying my WML documents. At first, I was puzzled by the fact that these documents were properly rendered in the Phone.com emulator and not on the real life phone. But, after the usual debugging process, I was even more puzzled to discover that this brand new phone was only able to render HDML files! So, don't view HDML as a thing of the past, this is not yet the case.

You can figure this out yourself with a Phone.com emulator (you can get one by downloading the wireless SDK at their site http://www.phone.com). First, type the following URL in the address text box: http://netdrive.com. Then pay attention to the received document's MIME type in the trace window. As you'll notice, the home page's MIME type is set to text/x-hdml. Now, go to the Phone.com site (by entering http://phone.com in the address text box), and notice that this time the MIME type is set to text/vnd.wap.wml. The former MIME type indicates that the document is an HDML document, and the latter that the document is a WML document.

OK, have you tried that by yourself? No? What are you waiting for? Try it, and you will notice another interesting fact. The netdrive.com site can be reached from both a desktop browser and a phone device (or an emulator) with the same URL. In fact, its HTTP server and, more particularly, the server's application, detects the user agent requesting a "home" document and sends an HDML document for a phone device and an HTML document for a desktop browser. Expect to see more sites behaving intelligently when different user agents request a document from them.

For instance, an intelligent site would send different home pages for different devices:

  • An I-Mode, HDML, or WML document for digital phones
  • An HTML document for desktop browsers
  • A VoiceXML document for voice browsers or phones

You may have noticed "VoiceXML for phones" there. We'll keep a fuller exposition of VoiceXML for another column, but for now think about accessing a VoiceXML document through a regular phone, and then how many phones there are on the planet. This will give you an idea of the potential of the VoiceXML technology, just now appearing on the scene.

Creating HDML

Is it possible to create an HDML document from XSLT? Yes, if you are using XT. An HDML Output handler kit is available from the http://www.4xt.org site. After having installed the HDML output handler, include in your XSLT style sheet the following declaration to tell the XT engine that HDML output is required--and thus obtain the proper behavior with standalone elements.

<xsl:output method="java:HDMLOutputHandler"

         xmlns:java="http://www.jclark.com/xt/java" />

An XSLT template should contain well formed XML elements. This is incompatible with HDML. What to do then? For instance, if a template requires a standalone element like <ACTION>, we simply include it as a well-formed XML element like this:

<xsl:template match="page">

<P>

  This is a simple example<BR/>

  <ACTION TYPE="ACCEPT" LABEL="Sample" TASK="GO" 

    DEST="#Sample"/>

</P>

<xsl:apply-templates/>

</xsl:template>

The output created by the HDML Output handler will modify the well-formed XML document into an SGML-based HDML document, as below:


<P>

  This is a simple example<BR>

  <ACTION TYPE="ACCEPT" LABEL="Sample" TASK="GO"

    DEST="#Sample">

</P>

The <BR/> is changed to <BR>. The same treatment is applied to the ACTION element.

Another solution to transforming XML into HDML is to use DSSSL and the OpenJade toolset, with the extension James Clark created to produce SGML elements instead of DSSSL formatting objects. For instance, the transformation from the previous example would be stated in DSSSL as follows:


(element Page

    (make element

          gi: "P"

          (make empty-element 

               gi: "ACTION" 

               attributes: "TYPE=ACCEPT LABEL=Sample TASK=GO DEST=#Sample"

           ) 

     )

     (process-children)

)

Or, if you use an HDML library, as follows:


(element Page

     (make P

         (make ACTION

              TYPE: "ACCEPT"

              LABEL: "Sample"

              TASK: "GO"

              DEST: "#Sample"

        )

     )

     (process-children)

)

Actually, the OpenJade package does not support the query rule that allows matching a construction rule to either an element or an attribute. The element rule can only be matched with an element. A construction rule is the rule's body containing all the "make" functions. A "make" function creates an element in the output tree.

Resources
 • OpenJade: http://www.netfolder.com/DSSSL
 • WML/HDML SDK: http://www.phone.com
 • HDML Output handler for XT: http://www.4xt.org
 • XT: http://www.jclark.com
 • WAP: http://www.wap.org

So, OpenJade can be used for simple XML to HDML transformations, where element matching is sufficient. When more sophisticated transformations are required, or if the XSLT syntax is more familiar to you, XT with the HDML Output handler should be used. A big advantage of using XT is that you can also chunk the XML document into several smaller HDML documents. In that sense, XT offers better features, and I would recommend it for XML to HDML transformation.