In a previous article, we made our initial foray into XSLT and XPath, finishing with an example that
demonstrated the transformation of XML into HTML. Now that we have seen the stylesheet for transforming XML into HTML, we can
now look at how we can transform XML into WML.
Looking at the stylesheet below, you can see that it is quite similar to the stylesheet for transforming
to HTML. Before we look into the differences, let's see how this stylesheet can be applied to the XML document.
From hrs to hrs
Recall that the earlier example performs the transformation on the client-side? That is, the web browser,
IE5, performed the transformation. In the case of WAP, it is not possible for the WAP device to perform the
transformation since they are typically "dumb" devices with limited processing power (at least for the moment).
What we need to do here is to perform the transformation on the server-side. In other words, the web server
will transform the XML document into WML.
To do that, we will make use of the Microsoft Active Server Pages (ASP) technology
and the Microsoft Document Object Model (DOM) to do the transformation:
'---Create an instance of the DOM object---
Set xml = Server.CreateObject("MSXML2.DOMDocument")
'---Let it run synchronously---
xml.async = false
'---Load the XML document---
Set xsl = Server.CreateObject("MSXML2.DOMDocument")
xsl.async = false
'---Load the XSLT stylesheet---
'---Set the MIME type---
Response.ContentType = "text/vnd.wap.wml"
'---Send the WML prologue---
'---Performs the transformation---
To view the above document in a WAP device, simply key in the URL:
You would need a web server and a WAP emulator to try this example. Here I am using the Microsoft IIS 4.0 and UP.Simulator by Phone.com: