spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / xml / column16

Transforming RSS into HTML and WAP II

WML output

Engineer Project Manager
Aquent
US-TX-Houston

Justtechjobs.com Post A Job | Post A Resume
Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

The Wireless Markup Language (WML) is a smaller and less powerful variant of HTML, conceived as the display markup for mobile phones and PDAs. Details can be found in column12.

Differences between HTML and WML

For our little example the following differences are relevant: So we develop a sister style sheet to RSS2HTML, called RSS2WML, that transforms the same RSS input into the WML format instead of HTML:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">

<xsl:output method="wml"/>
We changed the output method, although WML is not a recognized method yet and therefore currently ignored. We're planning ahead for when this will change.
  <xsl:template match="/">
    <WML><CARD ID="id1" TITLE="RSS newsfeed">
      <xsl:apply-templates/>
    </CARD></WML>
  </xsl:template>
Here we change the familiar structure of HTML and BODY into the WML version of WML and CARD.
  <xsl:template match="channel">
    <DO TYPE="accept">
      <xsl:attribute name="LABEL">
        <xsl:value-of select="title"/>
      </xsl:attribute>
      <GO>
      <xsl:attribute name="HREF">
        <xsl:value-of select="link"/>
      </xsl:attribute>
      </GO>
    </DO>
  </xsl:template>

  <xsl:template match="item">
    <DO TYPE="accept">
      <xsl:attribute name="label">
        <xsl:value-of select="title"/>
      </xsl:attribute>
      <GO>
      <xsl:attribute name="HREF">
        <xsl:value-of select="link"/>
      </xsl:attribute>
      </GO>
    </DO>
  </xsl:template>

  <xsl:template match="text()"/>

</xsl:stylesheet>
Finally we need to replace the TABLE and A anchor formatting with the DO/GO pair of tags specified in WML. The finished product is RSS2WML. If you have a WAP-enabled mobile phone or a WAP development toolkit you can look at the WML output.

Conclusion

XSL is a flexible solution for converting an XML-based input format such as RSS into various output formats. The case study here demonstrated the transformation into HTML with CSS and WAP/WML. Non-XML based output such as RTF, PDF, GIF etc. is also possible, and we might get back to this topic in a later installment of this column.

http://www.internet.com

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags

Produced by Michael Claßen
All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/xml/column16/2.html
Created: Aug 01, 2000
Revised: Aug 01, 2000