Publishing Formats

   

Ultimately, a servlet takes the XML document in Listing 4.1 and publishes it in HTML, WML, or RSS. WML is used for wireless applications, such as mobile phones, whereas RSS is used for portals.

I assume you are familiar with HTML, but I will introduce WML and RSS.

WML

You can think of WML as an HTML for mobile users. You will recognize several HTML elements in WML, such as <p> , <b> , and <small> .

However, WML differs from HTML in at least one aspect: It is not organized in pages but as a deck of cards. As we will see, this is to accommodate the smaller screens of mobile phones.

In effect, the user downloads not one page but a set of related pages (called cards ). See Figure 4.3 for an illustration of this concept.

Figure 4.3. A WML document is a set of cards.

graphics/04fig03.gif

Another difference between HTML and WML is that WML is an XML application; it respects the XML syntax. In other words, start and end tags must match. Listing 4.2 illustrates a WML document.

Listing 4.2 WML Document
 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"                      "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card title="Pineapplesoft Daily" id="toc">    <p align="center"><b>Today's News</b></p>    <p><anchor>Applied XML Solutions<go href="#N8"/></anchor></p>    <p><anchor>Jetty<go href="#N28"/></anchor></p>    <p><anchor>Hypersonic SQL<go href="#N46"/></anchor></p> </card> <card title="Pineapplesoft Daily" id="N8">    <p align="center"><b>Applied XML Solutions</b></p>    <p><small>by Beno&#238;t Marchal</small></p>    <p>A new intermediate/advanced book for XML developers.</p>    <p><small><anchor>More News...<go       href="#toc"/></anchor></small></p>    <p>Learn advanced XML programming with Applied XML Solutions.       This hands-on teaching book is filled with practical       examples.</p>    <p>Applied XML Solutions is a great complement to XML by       Example.</p>    <p><anchor>More News...<go href="#toc"/></anchor></p> </card> <card title="Pineapplesoft Daily" id="N28">    <p align="center"><b>Jetty</b></p>    <p><small>by Greg Wilkins</small></p>    <p>Open Source Java Server.</p>    <p><small><anchor>More News...<go       href="#toc"/></anchor></small></p>    <p>Jetty is a powerful, open-source Java web server.       It supports standard Java servlets making it the ideal       development environment.</p>    <p>Jetty is also highly-configurable which helps custom       developments.</p>    <p><anchor>More News...<go href="#toc"/></anchor></p> </card> <card title="Pineapplesoft Daily" id="N46">    <p align="center"><b>Hypersonic SQL</b></p>    <p><small>by Thomas M&#252;ller</small></p>    <p>Open Source SQL Database.</p>    <p><small><anchor>More News...<go       href="#toc"/></anchor></small></p>    <p>Hypersonic SQL is an open source database that supports       the JDBC API.</p>    <p>Hypersonic SQL is efficient and can run in three modes:       in-memory, standalone or client/server. This provides       lots of flexibility when writing software.</p>    <p><anchor>More News...<go href="#toc"/></anchor></p> </card> </wml> 

Thanks to the XML declaration, there is no mistaking an XML document. The DOCTYPE statement is required and must point to the WAP DTD:

 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"                         "http://www.wapforum.org/DTD/wml_1.1.xml"> 

The document itself is a deck of cards in which each card is presented independently. Cards are used to break a large document into smaller pieces. When using a small screen (obviously mobile phones have small screens), it is best to break information into smaller chunks :

 <card title="Pineapplesoft Daily" id="N8">       <p align="center"><b>Applied XML Solutions</b></p>       <p><small>by Beno&#238;t Marchal</small></p>       <p>A new intermediate/advanced book for XML developers.</p>       <p><small><anchor>More News...<go          href="#toc"/></anchor></small></p>       <p>Learn advanced XML programming with Applied XML Solutions.          This hands-on teaching book is filled with practical          examples.</p>       <p>Applied XML Solutions is a great complement to XML by          Example.</p>       <p><anchor>More News...<go href="#toc"/></anchor></p>    </card> 

As its name implies, the title attribute is the card title. The id attribute, on the other hand, is used to navigate between cards.

The <p> , <b> , and <small> elements correspond to paragraph, bold, and smaller font. They work similarly to their HTML counterparts.

When used together, the <anchor> and <go> elements are equivalent to HTML's <A> . Internal links (links that start with # ) are used to navigate between cards. For example, <go href="#toc"/> jumps to the toc card.

This chapter presents only a subset of WML. You will find more information at http://www.wapforum.org.

To view a WAP site, you must have a WAP browser. It won't work with Internet Explorer or Netscape. The main browsers available are as follows :

  • A WAP-enabled telephone ” For example, the Ericsson R320 (http://www.ericsson.com) or the Nokia 7710 (http://www.nokia.com)

  • A PalmPilot browser ” For example, WAPman (http://www.wap.com.sg) or 4thpass Kbrowser (http://www.4thpass.com/kbrowser)

  • A PC browser ” For example, WinWAP (http://www.winwap.org) or, again, WAPman (http://www.wap.com.sg)

  • A mobile phone emulator ” For example, the Nokia WAP Toolkit (http://www.forum.nokia.com)

The Nokia WAP Toolkit is particularly attractive for development. Figure 4.4 shows Listing 4.2 in the Nokia emulator.

Figure 4.4. Using the Nokia emulator.

graphics/04fig04.gif

Note

The WAP documentation mentions a WAP gateway sitting between the browser and the Web server.

Because mobile phones are slow, typically running at 9,600bps, the WAP gateway is used. This gateway is a specialized proxy that retrieves WML documents from regular Web servers and compresses them before passing them to the phone. It also communicates with the phone over a special protocol that is more efficient than HTTP.

WAP gateways are operated by phone companies and are required mainly for mobile phones. However, other browsers, such as WinWAP, can read the raw WML.


Tip

WML is a new markup language. Expect some surprises as you develop for this young medium. For example, I have found that the Ericsson R320 has difficulties with accentuated characters .


RSS

RSS (Rich Site Summary) is a markup language for portals. Imagine your company is writing a quality daily review of developer products. Wouldn't it be great if you could list these reviews on the main portals such as Yahoo! and Netcenter? You bet it would.

So far Yahoo! does not support RSS, but Netcenter does as part of My Netscape. Figure 4.5 shows My Netscape. The various boxes are in fact RSS documents.

Figure 4.5. RSS on the My Netscape portal.

graphics/04fig05.gif

How does it work? The content provider publishes an RSS file on his Web site (see Figure 4.6). Periodically, the portal fetches the file and presents it to visitors . This is called content syndication : The content owner syndicates his content to the portal.

This takes the separation between authoring and publishing one step further. With RSS, the content provider performs the authoring and the portal performs the publishing. As we will see, RSS does not include formatting elements ”formatting is the responsibility of the portal.

Figure 4.6. RSS enables content syndication.

graphics/04fig06.gif

Listing 4.3 is a simple RSS document.

Listing 4.3 RSS Document
 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE rss PUBLIC    "-//Netscape Communications//DTD RSS 0.91//EN"    "http://my.netscape.com/publish/formats/rss-0.91.dtd"> <rss version="0.91"><channel>    <title>Pineapplesoft Daily</title>    <description>Your source for technology news, trends and       facts of interest to web developers.</description>    <link>http://www.pineapplesoft.com</link>    <language>en</language>    <item>       <title>Applied XML Solutions</title>       <link>http://localhost:8080/publish/index#N8</link>       <description>A new intermediate/advanced book for XML          developers.</description>    </item>    <item>       <title>Jetty</title>       <link>http://localhost:8080/publish/index#N28</link>       <description>Open Source Java Server.</description>    </item>    <item>       <title>Hypersonic SQL</title>       <link>http://localhost:8080/publish/index#N46</link>       <description>Open Source SQL Database.</description>    </item> </channel></rss> 

Again, this is unmistakably an XML document, and the DOCTYPE statement is required:

 <!DOCTYPE rss PUBLIC       "-//Netscape Communications//DTD RSS 0.91//EN"       "http://my.netscape.com/publish/formats/rss-0.91.dtd"> 

An RSS document contains one (and only one) channel. The channel must have at least the following elements:

  • title ”The channel title

  • description ”A short introduction to the channel

  • link ”The Web page associated with the channel

  • language ”The channel's language

The channel also contains zero, one, or more <item> elements, where each <item> has a title , link , and description . As you can see, RSS is optimized for portals and search engines; it offers summaries and links to the complete articles on the content provider's Web site.

For more information on RSS, you can go to http://my.netscape.com/publish/help/mnn20/quickstart.html. Other sites that have adopted RSS include My Userland (http://my.userland.com) and XMLTree (http://www.xmltree.com). The latter deserves a special mention: XMLTree is a catalog of all the XML content on the Internet. You will find it useful when looking for documents to include on your own site.

   


Applied XML Solutions
Applied XML Solutions
ISBN: 0672320541
EAN: 2147483647
Year: 1999
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net