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 "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
If bSummary Then
' For WML Summary, output the article titles as options
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "
" & vbCrLf
Response.Write "" & vbCrLf
End If
' Write WML Footer
Response.Write "" & 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:
May 30, 2000
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:
This is the heading for the first article
This is the first paragraph for the first article.
This is the second paragraph for the first article.
This is the third paragraph for the first article.
This is the fourth paragraph for the first article.
This is the fifth paragraph for the first article.
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.
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