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
 
INDEX
>XMLCast Introduction
>Parsing the XML
>Output as [simple]HTML
>Output as RSS
>Output as WML

Content Management and Distribution Using XML

Output as WML

Even though outputting as WML is essentially pulling data from one XML document and inserting it into another, it's not quite as easy as outputting as RSS. Because of the limitations of WAP devices' display, we need to cut the data into separate s. We chose to split the paragraphs into their own cards, so that if someone requests a full article, it comes over as one card for each paragraph. Thus arises some of the problems with WAP, but that's another story.

Here's the outWML function:

outWML function

Private Sub outWML(bSummary) ' ********************************* ' This subroutine outputs the WML cards ' For the summary (If bSummary = True) or main article ' ********************************* Dim sHeading ' HEADING Dim sLink ' LINK Dim sSummary ' SUMMARY ' get Request.Form for articles qsLink = Request.Form("Articles") ' make sure the mime type is set Response.ContentType = "text/vnd.wap.wml" ' output required WML Headers, regardless of summary or not Response.Write "<?xml version=""1.0""?>" & vbCrLf Response.Write "<!DOCTYPE wml PUBLIC ""-//WAPFORUM//DTD WML 1.1//EN"" _ ""http://www.wapforum.org/DTD/wml_1.1.xml"">" & vbCrLf Response.Write "<wml>" & vbCrLf If bSummary Then ' For WML Summary, output the article titles as options Response.Write "<card id=""summary"" title=""WDN News "">" & vbCrLf Response.Write "<do type=""accept"" label=""Go"">" & vbCrLf Response.Write "<go href =""xmlcast.asp?out=wml"" method=""post"">" & vbCrLf Response.Write "<postfield name=""Articles"" value=""$(Articles)""/>" & vbCrLf Response.Write "</go>" & vbCrLf Response.Write "</do>" & vbCrLf Response.Write "<p>" & vbCrLf Response.Write "<em>" & sDate & "</em>" & vbCrLf Response.Write "<br/>" & vbCrLf Response.Write "<select name=""Articles"" title=""Articles"">" & vbCrLf End If ' Loop through Articles Dim i ' generic counter For i = 1 to UBound(arArticles) ' Set variables sHeading = arArticles(i).Heading sLink = arArticles(i).Link sSummary = arArticles(i).Summary If bSummary Then Response.Write "<option value=" & chr(34) & sLink & chr(34) & ">" _ & sHeading & "</option>" & vbCrLf Else If qsLink = "" Then qsLink = "news1" 'Set default to first story If qsLink = sLink Then ' For full WML Article, output the paragraphs as cards Dim p ' paragraph counter For p = 1 to UBound(arArticles(i).Paras) Response.Write "<card id = ""para" & p & chr(34) & " _ title=""News"">" & vbCrLf If p = 1 Then Response.Write "<p><em>" & sHeading & _ "</em></p>" & vbCrLf Response.Write "<p>" & vbCrLf Response.Write arArticles(i).Paras(p) & vbCrLf Response.Write "</p>" & vbCrLf If p < UBound(arArticles(i).Paras) Then Response.Write "<do type=""accept"" label=""Next"">" & vbCrLf Response.Write "<go href=""#para" & (p+1) & chr(34) & "/>" & vbCrlf Response.Write "</do>" & vbCrLf Else Response.Write "<do type=""accept"" label=""Home"">" & vbCrlf Response.Write "<go href=""xmlcast.asp?out=wmlsummary""/>" & vbCrLf Response.Write "</do>" & vbCrLf End If Response.Write "</card>" & vbCrLf Next ' p Exit For End If End If Next ' i If bSummary Then Response.Write "</select>" & vbCrLf Response.Write "</p>" & vbCrLf Response.Write "</card>" & vbCrLf End If ' Write WML Footer Response.Write "</wml>" & vbCrLf End Sub Again, we use our ParseXML function to extract the XML data from our document. Once we have our Article classes filled, outWML sets the context type to "text/vnd.wml.wap" so the web server doesn't sent out our wml as text. Then we write out the WML headers. Then, we check to see if the user requested a summary page or the full article.

For the summary page, we build a SELECT list that gives each article's title as an option. Here's what the outputted WML looks like:

<?xml version='1.0'?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="summary" title="WDN News "> <do type="accept" label="Go"> <go href ="xmlcast.asp?out=wml" method="post"> <postfield name="Articles" value="$(Articles)"/> </go> </do> <p> <em>May 30, 2000</em> <br/> <select name="Articles" title="Articles"> <option value="news1">This is the heading for the first article</option> <option value="news2">This is the heading for the second article.</option> <option value="news3">This is the heading for the third article.</option> </select> </p> </card> </wml> Once the user selects a title, the link for the article is passed via a form post to XMLCast. Once the chosen full article is retrieved, each paragraph is separated into cards and sent to the display. Each following paragraph can be called sequentially with the "Next" action. When you get to the last paragraph, the "Home" action sends you back to the summary page. Here's an example article in WML: <?xml version='1.0'?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id = "para1" title="News"> <p> <em>This is the heading for the first article</em> </p> <p> This is the first paragraph for the first article. </p> <do type="accept" label="Next"> <go href="#para2"/> </do> </card> <card id = "para2" title="News"> <p> This is the second paragraph for the first article. </p> <do type="accept" label="Next"> <go href="#para3"/> </do> </card> <card id = "para3" title="News"> <p> This is the third paragraph for the first article. </p> <do type="accept" label="Next"> <go href="#para4"/> </do> </card> <card id = "para4" title="News"> <p> This is the fourth paragraph for the first article. </p> <do type="accept" label="Next"> <go href="#para5"/> </do> </card> <card id = "para5" title="News"> <p> This is the fifth paragraph for the first article. </p> <do type="accept" label="Home"> <go href="xmlcast.asp?out=wmlsummary"/> </do> </card> </wml>

Conclusion

Taking the same content and formatting it for a number of different devices (regular HTML browsers, mobile or appliance simple HTML mini-browsers, and wireless phones displays) can turn a simple editing task into a formatting nightmare. XMLCast attempts to somewhat simplify this process, using an XML base to describe the data so it can be formatted for a particular device accordingly. In future articles, we'll explore some third-party tools and how they can be used with XMLCast to further enhance its multi-outputting capabilities.

Suggested Links:

About The Author: Marc Robards is a Microsoft Certified Solutions Developer who is searching for the perfect balance between Windows and Linux. Marc can be reached at marc@wirelessdevnet.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